remotes/1693045480750635534/spooky-22
Aevann1 2021-09-13 23:43:34 +02:00
parent 6ef59cd3f2
commit 14742ec344
5 changed files with 49 additions and 31 deletions

View File

@ -95,6 +95,7 @@ class User(Base, Stndrd, Age_times):
unban_utc = Column(Integer, default=0)
ban_reason = Column(String)
club_banned = Column(Boolean, default=False)
club_allowed = Column(Boolean, default=False)
login_nonce = Column(Integer, default=0)
reserved = Column(String(256))
coins = Column(Integer, default=0)
@ -157,8 +158,9 @@ class User(Base, Stndrd, Age_times):
return g.db.query(UserBlock).filter_by(
user_id=self.id, target_id=target.id).first()
@property
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):
@ -230,9 +232,7 @@ class User(Base, Stndrd, Age_times):
comments = comments.options(contains_eager(Comment.post))
if not v:
comments = comments.filter(Submission.club == False)
elif v.admin_level < 3 and (not v.paid_dues or v.club_banned):
if not (v and v.paid_dues):
comments = comments.filter(Submission.club == False)
now = int(time.time())

View File

@ -44,27 +44,46 @@ def revert_actions(v, username):
return {"message": "Admin actions reverted!"}
@app.post("/@<username>/club_ban")
@app.post("/@<username>/club_allow")
@admin_level_required(6)
def toggle_club_ban(v, username):
def club_allow(v, username):
u = get_user(username, v=v)
if not u:
abort(404)
if not u: abort(404)
if u.admin_level >= v.admin_level:
return {"error": "noob"}
if u.admin_level >= v.admin_level: 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:
x.club_banned = u.club_banned
x.club_allowed = True
x.club_banned = False
g.db.add(x)
return {
"message": f"@{username} has been kicked from the country club. Deserved." if u.club_banned else f"@{username}'s ban from club removed"
}
return {"message": f"@{username} has been allowed into the country club!"}
@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")

View File

@ -39,11 +39,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
comment = get_comment(cid, v=v)
if comment.post and comment.post.club:
if not v:
abort(403)
elif v.admin_level < 3 and (not v.paid_dues or v.club_banned):
abort(403)
if comment.post and comment.post.club and not (v and v.paid_dues): 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)

View File

@ -96,12 +96,7 @@ def post_id(pid, anything=None, v=None):
post = get_post(pid, v=v)
if post.club:
if not v:
abort(403)
elif v.admin_level < 3 and (not v.paid_dues or v.club_banned):
abort(403)
if post.club and not (v and v.paid_dues): abort(403)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()

View File

@ -328,8 +328,12 @@
<input type="submit" class="btn btn-danger" value="Remove User's Content">
</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>
<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>
{% if not u.club_allowed %}
<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 %}
<pre></pre>
<p>User ID: {{u.id}}</p>
@ -510,8 +514,12 @@
{% 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>
<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>
{% if not u.club_allowed %}
<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>
<div class="body d-lg-flex border-bottom">