From dbb7296dd7116c6bc11565dd92623271ea30cce3 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sun, 23 Oct 2022 17:17:49 -0500 Subject: [PATCH] stickies: allow JL2 to sticky post stickies: unpin on removal stickies: don't allow removed posts to be stickied --- files/helpers/const.py | 2 +- files/routes/admin.py | 7 +++---- files/routes/awards.py | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index b08b3e389..9e1a2860d 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -190,7 +190,7 @@ PERMS = { # Minimum admin_level to perform action. 'POST_TO_POLL_THREAD': 2, 'POST_BETS': 3, 'POST_BETS_DISTRIBUTE': 3, # probably should be the same as POST_BETS but w/e - 'BYPASS_PIN_LIMIT': 3, + 'BYPASS_PIN_LIMIT': 2, 'VIEW_PENDING_SUBMITTED_MARSEYS': 3, 'VIEW_PENDING_SUBMITTED_HATS': 3, 'MODERATE_PENDING_SUBMITTED_MARSEYS': 3, # note: there is an extra check so that only """carp""" can approve them diff --git a/files/routes/admin.py b/files/routes/admin.py index c49fb6912..22dc0e62e 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1121,11 +1121,11 @@ def remove_post(post_id, v): post = get_post(post_id) post.is_banned = True post.is_approved = None + post.stickied = None + post.is_pinned = False post.ban_reason = v.username g.db.add(post) - - ma=ModAction( kind="ban_post", user_id=v.id, @@ -1205,9 +1205,8 @@ def distinguish_post(post_id, v): @admin_level_required(PERMS['POST_COMMENT_MODERATION']) @feature_required('PINS') def sticky_post(post_id, v): - post = get_post(post_id) - + if post.is_banned: abort(403, "Can't sticky removed posts!") if post.stickied.endswith('(pin award)'): abort(403, "Can't pin award pins!") diff --git a/files/routes/awards.py b/files/routes/awards.py index b700509f3..eac872875 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -219,8 +219,8 @@ def award_thing(v, thing_type, id): author.unban_utc = int(time.time()) + 30 * 86400 send_repeatable_notification(author.id, f"Your account has been banned permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass/snow/sand/ass to get unbanned!") elif kind == "pin": - if not FEATURES['PINS']: - abort(403) + if not FEATURES['PINS']: abort(403) + if thing.is_banned: abort(403) if thing.stickied and thing.stickied_utc: thing.stickied_utc += 3600 else: @@ -232,7 +232,7 @@ def award_thing(v, thing_type, id): g.db.add(thing) cache.delete_memoized(frontlist) elif kind == "unpin": - if not thing.stickied_utc: abort(403) + if not thing.stickied_utc: abort(400) if thing.author_id == LAWLZ_ID and SITE_NAME == 'rDrama': abort(403, "You can't unpin lawlzposts!") if thing_type == 'comment':