awards: only restrict admins if award feature flag set

master
justcool393 2022-10-31 18:11:49 -05:00
parent 5d9ff04ad3
commit b17ea4fd37
1 changed files with 5 additions and 6 deletions

View File

@ -1029,7 +1029,7 @@ def unban_user(user_id, v):
if not user.is_banned: if not user.is_banned:
abort(400) abort(400)
if user.ban_reason and user.ban_reason.startswith('1-Day ban award'): if FEATURES["AWARDS"] and user.ban_reason and user.ban_reason.startswith('1-Day ban award'):
abort(403, "You can't undo a ban award!") abort(403, "You can't undo a ban award!")
user.is_banned = 0 user.is_banned = 0
@ -1092,7 +1092,7 @@ def remove_post(post_id, v):
post = get_post(post_id) post = get_post(post_id)
post.is_banned = True post.is_banned = True
post.is_approved = None post.is_approved = None
if post.stickied and not post.stickied.endswith(PIN_AWARD_TEXT): if FEATURES["AWARDS"] and post.stickied and not post.stickied.endswith(PIN_AWARD_TEXT):
post.stickied = None post.stickied = None
post.is_pinned = False post.is_pinned = False
post.ban_reason = v.username post.ban_reason = v.username
@ -1177,7 +1177,7 @@ def distinguish_post(post_id, v):
def sticky_post(post_id, v): def sticky_post(post_id, v):
post = get_post(post_id) post = get_post(post_id)
if post.is_banned: abort(403, "Can't sticky removed posts!") if post.is_banned: abort(403, "Can't sticky removed posts!")
if post.stickied and post.stickied.endswith(PIN_AWARD_TEXT): if FEATURES["AWARDS"] and post.stickied and post.stickied.endswith(PIN_AWARD_TEXT):
abort(403, "Can't pin award pins!") abort(403, "Can't pin award pins!")
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count() pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count()
@ -1216,7 +1216,7 @@ def sticky_post(post_id, v):
def unsticky_post(post_id, v): def unsticky_post(post_id, v):
post = get_post(post_id) post = get_post(post_id)
if post.stickied: if post.stickied:
if post.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!") if FEATURES["AWARDS"] and post.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!")
if post.author_id == LAWLZ_ID and post.stickied_utc and SITE_NAME == 'rDrama': abort(403, "Can't unpin lawlzposts!") if post.author_id == LAWLZ_ID and post.stickied_utc and SITE_NAME == 'rDrama': abort(403, "Can't unpin lawlzposts!")
post.stickied = None post.stickied = None
@ -1263,11 +1263,10 @@ def sticky_comment(cid, v):
@app.post("/unsticky_comment/<cid>") @app.post("/unsticky_comment/<cid>")
@admin_level_required(PERMS['POST_COMMENT_MODERATION']) @admin_level_required(PERMS['POST_COMMENT_MODERATION'])
def unsticky_comment(cid, v): def unsticky_comment(cid, v):
comment = get_comment(cid, v=v) comment = get_comment(cid, v=v)
if comment.stickied: if comment.stickied:
if comment.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!") if FEATURES["AWARDS"] and comment.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!")
comment.stickied = None comment.stickied = None
g.db.add(comment) g.db.add(comment)