From 3542703ced9d85ff952a5b5820b9f1aa363435d8 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 3 Dec 2022 00:08:46 +0200 Subject: [PATCH] Revert "make it so only the post author can declare winner and not all admins" This reverts commit 9e1425d93e7d8457a09c8c94b3660f707b148446. --- files/classes/submission.py | 2 +- files/helpers/const.py | 1 + files/routes/admin.py | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 8be7ae26d..22307759e 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -301,7 +301,7 @@ class Submission(Base): if o.exclusive == 3: body += " - WINNER!" - if not winner and v and v.id == self.author_id: + if not winner and v and v.admin_level >= PERMS['POST_BETS_DISTRIBUTE']: body += f'''''' body += "" else: diff --git a/files/helpers/const.py b/files/helpers/const.py index 44200865e..96ece78bc 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -249,6 +249,7 @@ PERMS = { # Minimum admin_level to perform action. 'POST_TO_CHANGELOG': 1, # note: code contributors can also post to changelog 'POST_TO_POLL_THREAD': 2, 'POST_BETS': 3, + 'POST_BETS_DISTRIBUTE': 3, # probably should be the same as POST_BETS but w/e '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 836e5b8fc..e68d343b7 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -191,7 +191,7 @@ def remove_admin(v, username): @app.post("/distribute/") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) -@auth_required +@admin_level_required(PERMS['POST_BETS_DISTRIBUTE']) def distribute(v, option_id): autojanny = get_account(AUTOJANNY_ID) if autojanny.coins == 0: abort(400, "@AutoJanny has 0 coins") @@ -209,9 +209,6 @@ def distribute(v, option_id): post = option.post - if v.id != post.author_id: - abort(403, "Only the post author can declare the winning bet!") - pool = 0 for o in post.options: if o.exclusive >= 2: pool += o.upvotes