From 19e9c1a20e2f69c49eb54311af5f21670c6fa10d Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Sat, 23 Jul 2022 03:03:26 -0500 Subject: [PATCH] Hide vote details from non-admins. It is intentional that the links show up on admin level 2 but aren't usable until admin level 3; I don't know what I want right now and I want to encourage admins to pester me about it. --- files/routes/users.py | 24 ++++++++++++------------ files/routes/votes.py | 2 +- files/templates/comments.html | 4 ++-- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- files/templates/userpage.html | 8 ++++++-- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index b38d5c6d8..7cd572c83 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -72,7 +72,7 @@ def leaderboard_thread(): gevent.spawn(leaderboard_thread()) @app.get("/@/upvoters//posts") -@auth_required +@admin_level_required(3) def upvoters_posts(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -93,7 +93,7 @@ def upvoters_posts(v, username, uid): @app.get("/@/upvoters//comments") -@auth_required +@admin_level_required(3) def upvoters_comments(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -114,7 +114,7 @@ def upvoters_comments(v, username, uid): @app.get("/@/downvoters//posts") -@auth_required +@admin_level_required(3) def downvoters_posts(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -135,7 +135,7 @@ def downvoters_posts(v, username, uid): @app.get("/@/downvoters//comments") -@auth_required +@admin_level_required(3) def downvoters_comments(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -159,7 +159,7 @@ def downvoters_comments(v, username, uid): @app.get("/@/upvoting//posts") -@auth_required +@admin_level_required(3) def upvoting_posts(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -180,7 +180,7 @@ def upvoting_posts(v, username, uid): @app.get("/@/upvoting//comments") -@auth_required +@admin_level_required(3) def upvoting_comments(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -201,7 +201,7 @@ def upvoting_comments(v, username, uid): @app.get("/@/downvoting//posts") -@auth_required +@admin_level_required(3) def downvoting_posts(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -222,7 +222,7 @@ def downvoting_posts(v, username, uid): @app.get("/@/downvoting//comments") -@auth_required +@admin_level_required(3) def downvoting_comments(v, username, uid): u = get_user(username) if u.is_private and v.id != u.id: abort(403) @@ -254,7 +254,7 @@ def grassed(v): @app.get("/@/upvoters") -@auth_required +@admin_level_required(3) def upvoters(v, username): id = get_user(username).id @@ -280,7 +280,7 @@ def upvoters(v, username): @app.get("/@/downvoters") -@auth_required +@admin_level_required(3) def downvoters(v, username): id = get_user(username).id @@ -304,7 +304,7 @@ def downvoters(v, username): return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'Who downvotes @{username}') @app.get("/@/upvoting") -@auth_required +@admin_level_required(3) def upvoting(v, username): id = get_user(username).id @@ -328,7 +328,7 @@ def upvoting(v, username): return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'Who @{username} upvotes') @app.get("/@/downvoting") -@auth_required +@admin_level_required(3) def downvoting(v, username): id = get_user(username).id diff --git a/files/routes/votes.py b/files/routes/votes.py index a0869937e..e97521bab 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -8,7 +8,7 @@ from os import environ @app.get("/votes") @limiter.limit("5/second;60/minute;200/hour;1000/day") -@auth_required +@admin_level_required(3) def admin_vote_info_get(v): link = request.values.get("link") if not link: return render_template("votes.html", v=v) diff --git a/files/templates/comments.html b/files/templates/comments.html index 0682d11be..5cda24d65 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -429,7 +429,7 @@ {% endif %} - {% if not c.ghost or v.id == AEVANN_ID %}Votes{% endif %} + {% if v.admin_level >= 2 %}Votes{% endif %} Context @@ -621,7 +621,7 @@