perms: consistently use >= for admin levels

places that use the PERMS constant do it and this way makes it clearer
what admin level is required to perform an action.
This commit is contained in:
justcool393 2023-04-04 04:08:17 -05:00 committed by Ben Rog-Wilhelm
parent 3bbedd7375
commit 688cd91e83
21 changed files with 50 additions and 50 deletions

View file

@ -118,7 +118,7 @@ def post_id(pid, anything=None, v=None):
if request.headers.get("Authorization"): return post.json
else:
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
if post.is_banned and not (v and (v.admin_level >= 2 or post.author_id == v.id)): template = "submission_banned.html"
else: template = "submission.html"
return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset)
@ -636,7 +636,7 @@ def undelete_post_pid(pid, v):
@auth_required
def toggle_comment_nsfw(cid, v):
comment = g.db.query(Comment).filter_by(id=cid).one_or_none()
if comment.author_id != v.id and not v.admin_level > 1: abort(403)
if comment.author_id != v.id and not v.admin_level >= 2: abort(403)
comment.over_18 = not comment.over_18
g.db.add(comment)
@ -650,7 +650,7 @@ def toggle_comment_nsfw(cid, v):
def toggle_post_nsfw(pid, v):
post = get_post(pid)
if post.author_id != v.id and not v.admin_level > 1:
if post.author_id != v.id and not v.admin_level >= 2:
abort(403)
post.over_18 = not post.over_18