From 1362278cb4dbe5d921a6872a6822d3fc42cd691b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 1 Jul 2022 01:39:09 +0200 Subject: [PATCH] add more data for jannies in /votes page (will use that in polls) --- files/routes/votes.py | 13 +++++++++++++ files/templates/votes.html | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/files/routes/votes.py b/files/routes/votes.py index 1ff55af04a..148ebf5abf 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -40,6 +40,19 @@ def admin_vote_info_get(v): downs = g.db.query(CommentVote).filter_by(comment_id=thing_id, vote_type=-1 ).order_by(CommentVote.created_utc).all() + if v.admin_level: + up_ids = [x[0] for x in g.db.query(CommentVote.user_id).filter_by(comment_id=thing_id, vote_type=1).order_by(CommentVote.created_utc).all()] + total_ups = g.db.query(func.sum(User.truecoins)).filter(User.id.in_(up_ids)).scalar() + patrons_ups = g.db.query(User).filter(User.id.in_(up_ids), User.patron > 0).count() + + return render_template("votes.html", + v=v, + thing=thing, + ups=ups, + downs=downs, + total_ups=total_ups, + patrons_ups=patrons_ups) + else: abort(400) return render_template("votes.html", diff --git a/files/templates/votes.html b/files/templates/votes.html index d0582ced16..1c0b0c2a9d 100644 --- a/files/templates/votes.html +++ b/files/templates/votes.html @@ -22,6 +22,11 @@

Upvotes: {{ups | length}}

Downvotes: {{downs | length}}

+{% if v.admin_level %} +

Total Truescore: {{total_ups}}

+

Total Paypigs: {{patrons_ups}}

+{% endif %} +

Upvotes