remotes/1693045480750635534/spooky-22
fireworks88 2021-09-12 20:25:59 +02:00
parent b8fd241843
commit fb3b5ea453
6 changed files with 50 additions and 17 deletions

View File

@ -93,6 +93,7 @@ class User(Base, Stndrd, Age_times):
is_banned = Column(Integer, default=0)
unban_utc = Column(Integer, default=0)
ban_reason = Column(String)
club_banned = Column(Boolean, default=False)
login_nonce = Column(Integer, default=0)
reserved = Column(String(256))
coins = Column(Integer, default=0)

View File

@ -45,6 +45,28 @@ def revert_actions(v, username):
return {"message": "Admin actions reverted!"}
@app.post("/@<username>/club_ban")
@admin_level_required(6)
def toggle_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 = not u.club_banned
for x in u.alts:
x.club_banned = not x.club_banned
return {
"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>/make_admin")
@admin_level_required(6)
def make_admin(v, username):

View File

@ -41,7 +41,11 @@ 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 and not (v and v.coins > 150): abort(403)
if comment.post and comment.post.club:
if not v:
abort(403)
elif v.admin_level < 3 and (v.coins < 750 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)

View File

@ -33,7 +33,7 @@ def toggle_club(pid, v):
post = get_post(pid)
if not post.author_id == v.id and not v.admin_level >= 3: abort(403)
if not (post.author_id == v.id and not v.club_banned) or not v.admin_level >= 3: abort(403)
post.club = not post.club
g.db.add(post)
@ -88,18 +88,6 @@ def post_id(pid, anything=None, v=None):
if v: defaultsortingcomments = v.defaultsortingcomments
else: defaultsortingcomments = "top"
sort=request.args.get("sort", defaultsortingcomments)
try: pid = int(pid)
except:
@ -108,7 +96,12 @@ def post_id(pid, anything=None, v=None):
post = get_post(pid, v=v)
if post.club and not (v and v.coins > 150): abort(403)
if post.club:
if not v:
abort(403)
elif v.admin_level < 3 and (v.coins < 750 or v.club_banned):
abort(403)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()

View File

@ -375,10 +375,10 @@
<label class="custom-control-label" for="privateCheck">Draft</label>
</div>
{% if v.admin_level == 6 or v.coins > 150 %}
{% if v.admin_level == 6 or (v.coins >= 750 and not v.club_banned) %}
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="clubCheck" name="club">
<label class="custom-control-label" for="clubCheck">+150 coins to view</label>
<label class="custom-control-label" for="clubCheck">Country Club thread</label>
</div>
{% endif %}
<pre>

View File

@ -327,6 +327,12 @@
<input type="hidden" name="user" value="{{u.username}}">
<input type="submit" class="btn btn-danger" value="Remove User's Content">
</form>
{% if u.club_banned %}
<button class="btn btn-success" onclick="post_toast('/@{{u.username}}/club_ban')">Grant club access</button>
{% else %}
<button class="btn btn-danger" onclick="post_toast('/@{{u.username}}/club_ban')">Bar from club</button>
{% endif %}
{% endif %}
<pre></pre>
<p>User ID: {{u.id}}</p>
@ -505,6 +511,13 @@
</div>
{% if v.admin_level > 1 %}
{% if u.club_banned %}
<button class="btn btn-success" onclick="post_toast('/@{{u.username}}/club_ban')">Grant club access</button>
{% else %}
<button class="btn btn-danger" onclick="post_toast('/@{{u.username}}/club_ban')">Bar from club</button>
{% endif %}
<br><br>
<div class="body d-lg-flex border-bottom">