From 3c46fcdc7f826ec6afa01bdb5a76407cc7c6b160 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 25 Jul 2021 17:05:14 +0200 Subject: [PATCH] df --- drama/routes/admin.py | 61 ++----------------------------------------- drama/routes/votes.py | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/drama/routes/admin.py b/drama/routes/admin.py index faac5765e4..b04e1ab68c 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -193,11 +193,11 @@ def badge_grant_post(v): send_notification(1046, user, text) - if badge_id in [21,22,23,24]: + if badge_id in [21,22,23,24,28]: user.patron = True user.animatedname = True if badge_id == 23: user.banawards = 1 - elif badge_id == 24: user.banawards = 3 + elif badge_id in [24,28]: user.banawards = 3 g.db.add(user) return redirect(user.permalink) @@ -261,63 +261,6 @@ def participation_stats(v): return render_template("admin/content_stats.html", v=v, title="Content Statistics", data=data) - -@app.route("/votes", methods=["GET"]) -@auth_desired -def admin_vote_info_get(v): - if v and v.is_banned and not v.unban_utc: return render_template("seized.html") - - link = request.args.get("link") - if not link: return render_template("admin/votes.html", v=v) - - ids = re.search("://[^/]+\w+/post/(\w+)/[^/]+(/(\w+))?", link) - - try: - post_id = ids.group(1) - comment_id = ids.group(3) - except: abort(400) - - if comment_id: - thing = get_comment(int(comment_id), v=v) - - else: - thing = get_post(int(post_id), v=v) - - - if isinstance(thing, Submission): - - ups = g.db.query(Vote - ).options(joinedload(Vote.user) - ).filter_by(submission_id=thing.id, vote_type=1 - ).all() - - downs = g.db.query(Vote - ).options(joinedload(Vote.user) - ).filter_by(submission_id=thing.id, vote_type=-1 - ).all() - - elif isinstance(thing, Comment): - - ups = g.db.query(CommentVote - ).options(joinedload(CommentVote.user) - ).filter_by(comment_id=thing.id, vote_type=1 - ).all() - - downs = g.db.query(CommentVote - ).options(joinedload(CommentVote.user) - ).filter_by(comment_id=thing.id, vote_type=-1 - ).all() - - else: - abort(400) - - return render_template("admin/votes.html", - v=v, - thing=thing, - ups=ups, - downs=downs,) - - @app.route("/admin/alt_votes", methods=["GET"]) @admin_level_required(4) def alt_votes_get(v): diff --git a/drama/routes/votes.py b/drama/routes/votes.py index f69d452d38..73ab3dbb18 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -5,6 +5,64 @@ from flask import * from drama.__main__ import app from .users import leaderboard + +@app.route("/votes", methods=["GET"]) +@auth_desired +def admin_vote_info_get(v): + if v and v.is_banned and not v.unban_utc: return render_template("seized.html") + + link = request.args.get("link") + if not link: return render_template("admin/votes.html", v=v) + + ids = re.search("://[^/]+\w+/post/(\w+)/[^/]+(/(\w+))?", link) + + try: + post_id = ids.group(1) + comment_id = ids.group(3) + except: abort(400) + + if comment_id: + thing = get_comment(int(comment_id), v=v) + + else: + thing = get_post(int(post_id), v=v) + + + if isinstance(thing, Submission): + + ups = g.db.query(Vote + ).options(joinedload(Vote.user) + ).filter_by(submission_id=thing.id, vote_type=1 + ).all() + + downs = g.db.query(Vote + ).options(joinedload(Vote.user) + ).filter_by(submission_id=thing.id, vote_type=-1 + ).all() + + elif isinstance(thing, Comment): + + ups = g.db.query(CommentVote + ).options(joinedload(CommentVote.user) + ).filter_by(comment_id=thing.id, vote_type=1 + ).all() + + downs = g.db.query(CommentVote + ).options(joinedload(CommentVote.user) + ).filter_by(comment_id=thing.id, vote_type=-1 + ).all() + + else: + abort(400) + + return render_template("admin/votes.html", + v=v, + thing=thing, + ups=ups, + downs=downs,) + + + @app.route("/api/v1/vote/post//", methods=["POST"]) @app.route("/api/vote/post//", methods=["POST"]) @is_not_banned