From 1220d06eabbde9a67c33c945943bebb0e4dfa42d Mon Sep 17 00:00:00 2001 From: justcool393 Date: Wed, 5 Oct 2022 22:37:50 -0700 Subject: [PATCH] some admin perms and also fix search --- files/helpers/const.py | 3 +++ files/routes/admin.py | 6 +++--- files/routes/search.py | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 738d29c50..2bc08d33c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -136,6 +136,7 @@ PERMS = { # Minimum admin_level to perform action. 'USER_SHADOWBAN': 2, 'USER_AGENDAPOSTER': 2, 'USER_CLUB_ALLOW_BAN': 2, + 'USER_LINK': 2, 'POST_TO_CHANGELOG': 1, 'POST_TO_POLL_THREAD': 2, 'POST_BETS': 3, @@ -158,6 +159,8 @@ PERMS = { # Minimum admin_level to perform action. 'VIEW_SORTED_ADMIN_LIST': 3, 'PRINT_MARSEYBUX_FOR_KIPPY_ON_PCMEMES': 3, 'VIEW_ACTIVE_USERS': 2, + 'VIEW_ALL_USERS': 2, + 'VIEW_ALT_VOTES': 2, 'MERGE_USERS': 3, # note: extra check for Aevann 'ADMIN_ADD': 3, # note: explicitly disabled on rDrama 'ADMIN_REMOVE': 3, diff --git a/files/routes/admin.py b/files/routes/admin.py index 543989432..cdca52e8a 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -626,7 +626,7 @@ def badge_remove_post(v): @app.get("/admin/users") -@admin_level_required(2) +@admin_level_required(PERMS['VIEW_ALL_USERS']) def users_list(v): try: page = int(request.values.get("page", 1)) @@ -647,7 +647,7 @@ def users_list(v): @app.get("/admin/alt_votes") -@admin_level_required(2) +@admin_level_required(PERMS['VIEW_ALT_VOTES']) def alt_votes_get(v): u1 = request.values.get("u1") @@ -754,7 +754,7 @@ def alt_votes_get(v): @app.post("/admin/link_accounts") @limiter.limit("1/second;30/minute;200/hour;1000/day") -@admin_level_required(2) +@admin_level_required(PERMS['USER_LINK']) def admin_link_accounts(v): u1 = int(request.values.get("u1")) diff --git a/files/routes/search.py b/files/routes/search.py index 1c7c22c0f..8f543a8aa 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -61,12 +61,14 @@ def searchposts(v): if not v.paid_dues: posts = posts.filter(Submission.club == False) - if v.admin_level < 2: + if v.admin_level < PERMS['POST_COMMENT_MODERATION']: posts = posts.filter( Submission.deleted_utc == 0, Submission.is_banned == False, - Submission.private == False, - User.shadowbanned == None) + Submission.private == False) + + if v.admin_level < PERMS['USER_SHADOWBAN']: + posts = posts.filter(User.shadowbanned == None) if 'author' in criteria: posts = posts.filter(Submission.ghost == False)