fd
This commit is contained in:
parent
1994df1bc7
commit
4367daf813
5 changed files with 49 additions and 31 deletions
|
@ -95,6 +95,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
unban_utc = Column(Integer, default=0)
|
unban_utc = Column(Integer, default=0)
|
||||||
ban_reason = Column(String)
|
ban_reason = Column(String)
|
||||||
club_banned = Column(Boolean, default=False)
|
club_banned = Column(Boolean, default=False)
|
||||||
|
club_allowed = Column(Boolean, default=False)
|
||||||
login_nonce = Column(Integer, default=0)
|
login_nonce = Column(Integer, default=0)
|
||||||
reserved = Column(String(256))
|
reserved = Column(String(256))
|
||||||
coins = Column(Integer, default=0)
|
coins = Column(Integer, default=0)
|
||||||
|
@ -157,8 +158,9 @@ class User(Base, Stndrd, Age_times):
|
||||||
return g.db.query(UserBlock).filter_by(
|
return g.db.query(UserBlock).filter_by(
|
||||||
user_id=self.id, target_id=target.id).first()
|
user_id=self.id, target_id=target.id).first()
|
||||||
|
|
||||||
|
@property
|
||||||
def paid_dues(self):
|
def paid_dues(self):
|
||||||
return self.truecoins > int(environ.get("DUES").strip())
|
return not self.club_banned and (self.admin_level == 6 or self.club_allowed or self.truecoins > int(environ.get("DUES").strip()))
|
||||||
|
|
||||||
def any_block_exists(self, other):
|
def any_block_exists(self, other):
|
||||||
|
|
||||||
|
@ -230,9 +232,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
comments = comments.options(contains_eager(Comment.post))
|
comments = comments.options(contains_eager(Comment.post))
|
||||||
|
|
||||||
if not v:
|
if not (v and v.paid_dues):
|
||||||
comments = comments.filter(Submission.club == False)
|
|
||||||
elif v.admin_level < 3 and (not v.paid_dues or v.club_banned):
|
|
||||||
comments = comments.filter(Submission.club == False)
|
comments = comments.filter(Submission.club == False)
|
||||||
|
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
|
|
|
@ -44,27 +44,46 @@ def revert_actions(v, username):
|
||||||
|
|
||||||
return {"message": "Admin actions reverted!"}
|
return {"message": "Admin actions reverted!"}
|
||||||
|
|
||||||
|
@app.post("/@<username>/club_allow")
|
||||||
@app.post("/@<username>/club_ban")
|
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
def toggle_club_ban(v, username):
|
def club_allow(v, username):
|
||||||
|
|
||||||
u = get_user(username, v=v)
|
u = get_user(username, v=v)
|
||||||
|
|
||||||
if not u:
|
if not u: abort(404)
|
||||||
abort(404)
|
|
||||||
|
|
||||||
if u.admin_level >= v.admin_level:
|
if u.admin_level >= v.admin_level: return {"error": "noob"}
|
||||||
return {"error": "noob"}
|
|
||||||
|
|
||||||
u.club_banned = not u.club_banned
|
u.club_allowed = True
|
||||||
|
u.club_banned = False
|
||||||
|
g.db.add(u)
|
||||||
|
|
||||||
for x in u.alts:
|
for x in u.alts:
|
||||||
x.club_banned = u.club_banned
|
x.club_allowed = True
|
||||||
|
x.club_banned = False
|
||||||
|
g.db.add(x)
|
||||||
|
|
||||||
return {
|
return {"message": f"@{username} has been allowed into the country club!"}
|
||||||
"message": f"@{username} has been kicked from the country club. Deserved." if u.club_banned else f"@{username}'s ban from club removed"
|
|
||||||
}
|
@app.post("/@<username>/club_ban")
|
||||||
|
@admin_level_required(6)
|
||||||
|
def club_ban(v, username):
|
||||||
|
|
||||||
|
u = get_user(username, v=v)
|
||||||
|
|
||||||
|
if not u: abort(404)
|
||||||
|
|
||||||
|
if u.admin_level >= v.admin_level: return {"error": "noob"}
|
||||||
|
|
||||||
|
u.club_banned = True
|
||||||
|
u.club_allowed = False
|
||||||
|
|
||||||
|
for x in u.alts:
|
||||||
|
x.club_banned = True
|
||||||
|
u.club_allowed = False
|
||||||
|
g.db.add(x)
|
||||||
|
|
||||||
|
return {"message": f"@{username} has been kicked from the country club. Deserved."}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/@<username>/make_admin")
|
@app.post("/@<username>/make_admin")
|
||||||
|
|
|
@ -39,11 +39,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
|
|
||||||
comment = get_comment(cid, v=v)
|
comment = get_comment(cid, v=v)
|
||||||
|
|
||||||
if comment.post and comment.post.club:
|
if comment.post and comment.post.club and not (v and v.paid_dues): abort(403)
|
||||||
if not v:
|
|
||||||
abort(403)
|
|
||||||
elif v.admin_level < 3 and (not v.paid_dues or v.club_banned):
|
|
||||||
abort(403)
|
|
||||||
|
|
||||||
if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level == 6) : abort(403)
|
if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level == 6) : abort(403)
|
||||||
|
|
||||||
|
|
|
@ -96,12 +96,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
post = get_post(pid, v=v)
|
post = get_post(pid, v=v)
|
||||||
|
|
||||||
if post.club:
|
if post.club and not (v and v.paid_dues): abort(403)
|
||||||
if not v:
|
|
||||||
abort(403)
|
|
||||||
elif v.admin_level < 3 and (not v.paid_dues or v.club_banned):
|
|
||||||
abort(403)
|
|
||||||
|
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
|
@ -328,8 +328,12 @@
|
||||||
<input type="submit" class="btn btn-danger" value="Remove User's Content">
|
<input type="submit" class="btn btn-danger" value="Remove User's Content">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<button id="banclub" class="{% if u.club_banned %}d-none{% endif %} btn btn-success" onclick="post_toast2('/@{{u.username}}/club_ban','banclub','unbanclub')">Ban from club</button>
|
{% if not u.club_allowed %}
|
||||||
<button id="unbanclub" class="{% if not u.club_banned %}d-none{% endif %} btn btn-success" onclick="post_toast2('/@{{u.username}}/club_ban','banclub','unbanclub')">Unban from club</button>
|
<button class="btn btn-success" onclick="post_toast('/@{{u.username}}/club_ban')">Grant club access</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if not u.club_banned %}
|
||||||
|
<button class="btn btn-danger" onclick="post_toast('/@{{u.username}}/club_allow')">Bar from club</button>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
<p>User ID: {{u.id}}</p>
|
<p>User ID: {{u.id}}</p>
|
||||||
|
@ -510,8 +514,12 @@
|
||||||
|
|
||||||
{% if v.admin_level > 1 %}
|
{% if v.admin_level > 1 %}
|
||||||
|
|
||||||
<button id="banclub2" class="{% if u.club_banned %}d-none{% endif %} btn btn-success" onclick="post_toast2('/@{{u.username}}/club_ban','banclub2','unbanclub2')">Ban from club</button>
|
{% if not u.club_allowed %}
|
||||||
<button id="unbanclub2" class="{% if not u.club_banned %}d-none{% endif %} btn btn-success" onclick="post_toast2('/@{{u.username}}/club_ban','banclub2','unbanclub2')">Unban from club</button>
|
<button class="btn btn-success" onclick="post_toast('/@{{u.username}}/club_ban')">Grant club access</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if not u.club_banned %}
|
||||||
|
<button class="btn btn-danger" onclick="post_toast('/@{{u.username}}/club_allow')">Bar from club</button>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
<div class="body d-lg-flex border-bottom">
|
<div class="body d-lg-flex border-bottom">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue