From dd3dfa519766175ca0de5c23ae9f3a1081353a8a Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 1 Jan 2023 16:52:16 +0200 Subject: [PATCH] make users list viewable by everypony --- files/helpers/config/const.py | 1 - files/routes/admin.py | 22 ---------------------- files/routes/users.py | 20 ++++++++++++++++++++ files/templates/admin/admin_home.html | 3 --- files/templates/sidebar_WPD.html | 10 ++-------- files/templates/sidebar_rDrama.html | 10 ++-------- 6 files changed, 24 insertions(+), 42 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 7bd96474e..77fdbf5e5 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -441,7 +441,6 @@ PERMS = { # Minimum admin_level to perform action. 'VIEW_PRIVATE_PROFILES': 2, 'VIEW_ALTS': 2, 'VIEW_ACTIVE_USERS': 2, - 'VIEW_ALL_USERS': 2, 'VIEW_ALT_VOTES': 2, 'VIEW_LAST_ACTIVE': 2, 'VIEW_PATRONS': 3, # note: extra check for Aevann, carp, or snakes diff --git a/files/routes/admin.py b/files/routes/admin.py index b87b58cff..8b8928b2b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -622,28 +622,6 @@ def badge_remove_post(v): return render_template("admin/badge_admin.html", v=v, badge_types=badges, grant=False, msg=f"{badge.name} Badge removed from @{user.username} successfully!") -@app.get("/admin/users") -@admin_level_required(PERMS['VIEW_ALL_USERS']) -def users_list(v): - - try: page = int(request.values.get("page", 1)) - except: page = 1 - - users = g.db.query(User).order_by(User.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all() - - next_exists = (len(users) > PAGE_SIZE) - users = users[:PAGE_SIZE] - - return render_template("user_cards.html", - v=v, - users=users, - next_exists=next_exists, - page=page, - user_cards_title="Users Feed", - ) - - - @app.get("/admin/alt_votes") @admin_level_required(PERMS['VIEW_ALT_VOTES']) def alt_votes_get(v): diff --git a/files/routes/users.py b/files/routes/users.py index 271397049..209757188 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1308,3 +1308,23 @@ def settings_kofi(v:User): badge_grant(badge_id=20+highest_tier, user=v) return {"message": f"{patron} rewards claimed!"} + +@app.get("/users") +@auth_required +def users_list(v): + + try: page = int(request.values.get("page", 1)) + except: page = 1 + + users = g.db.query(User).order_by(User.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all() + + next_exists = (len(users) > PAGE_SIZE) + users = users[:PAGE_SIZE] + + return render_template("user_cards.html", + v=v, + users=users, + next_exists=next_exists, + page=page, + user_cards_title="Users Feed", + ) diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index cb6acd4c4..ecb7d8296 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -40,9 +40,6 @@

Users