From 02efc44682912e556514ba136247a6d928d63dbd Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 1 Nov 2022 15:14:11 -0500 Subject: [PATCH] pins: reintroduce bug/feature at @Aevann1's request the old behavior was actually to let admins bypass the limit, but this was buggy when the new multi pin thing was added and wouldn't let jannies make permapins if pins were at the limit to make the code clear though, the permission name has been changed --- files/helpers/const.py | 2 +- files/routes/admin.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index f4b89d1899..a25492bd79 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': 2, + 'BYPASS_PIN_LIMIT_IF_TEMPORARY': 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 698fb481dd..361d6694c4 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1182,8 +1182,9 @@ def sticky_post(post_id, v): pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count() extra_pin_slots = 1 if post.stickied else 0 + sticky_time = int(time.time()) + 3600 if post.stickied_utc else None - if pins >= PIN_LIMIT + extra_pin_slots and v.admin_level < PERMS['BYPASS_PIN_LIMIT']: + if pins >= PIN_LIMIT + extra_pin_slots and v.admin_level < PERMS['BYPASS_PIN_LIMIT_IF_TEMPORARY'] and not sticky_time: abort(403, f"Can't exceed {PIN_LIMIT} pinned posts limit!") if not post.stickied_utc: