From a46402a2c65b3e3624cb5b3a909a27584c6fe428 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 30 Jul 2021 07:52:32 +0200 Subject: [PATCH] dffd --- drama/routes/votes.py | 7 +--- drama/templates/default.html | 71 +++++++----------------------------- 2 files changed, 16 insertions(+), 62 deletions(-) diff --git a/drama/routes/votes.py b/drama/routes/votes.py index b261bffb8..f9db25225 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -114,12 +114,9 @@ def api_vote_post(post_id, new, v): @validate_formkey def api_vote_comment(comment_id, new, v): - if new not in ["-1", "0", "1"]: - abort(400) + if new not in ["-1", "0", "1"]: abort(400) - # disallow bots - if request.headers.get("X-User-Type","") == "Bot": - abort(403) + if request.headers.get("X-User-Type","") == "Bot": abort(403) new = int(new) diff --git a/drama/templates/default.html b/drama/templates/default.html index acf3595ee..a35773ee5 100644 --- a/drama/templates/default.html +++ b/drama/templates/default.html @@ -773,65 +773,22 @@ } register_votes() - - function vote_comment(comment_id, direction) { - url="/api/vote/comment/"+ comment_id +"/"+direction; - - callback=function(){ - thing = document.getElementById("comment-"+ comment_id+"-actions"); - uparrow1=document.getElementById("comment-"+ comment_id +"-up"); - downarrow1=document.getElementById("comment-"+ comment_id +"-down"); - scoreup1=document.getElementById("comment-"+ comment_id +"-score-up"); - scorenone1=document.getElementById("comment-"+ comment_id +"-score-none"); - scoredown1=document.getElementById("comment-"+ comment_id +"-score-down"); - - if (direction=="1") { - thing.classList.add("upvoted"); - thing.classList.remove("downvoted"); - uparrow1.onclick=function(){vote_comment(comment_id, 0)}; - downarrow1.onclick=function(){vote_comment(comment_id, -1)}; - scoreup1.classList.remove("d-none"); - scorenone1.classList.add("d-none"); - scoredown1.classList.add("d-none"); - } - else if (direction=="-1"){ - thing.classList.remove("upvoted"); - thing.classList.add("downvoted"); - uparrow1.onclick=function(){vote_comment(comment_id, 1)}; - downarrow1.onclick=function(){vote_comment(comment_id, 0)}; - scoreup1.classList.add("d-none"); - scorenone1.classList.add("d-none"); - scoredown1.classList.remove("d-none"); - } - else if (direction=="0"){ - thing.classList.remove("upvoted"); - thing.classList.remove("downvoted"); - uparrow1.onclick=function(){vote_comment(comment_id, 1)}; - downarrow1.onclick=function(){vote_comment(comment_id, -1)}; - scoreup1.classList.add("d-none"); - scorenone1.classList.remove("d-none"); - scoredown1.classList.add("d-none"); - } - } - - post(url, callback, "Unable to vote at this time. Please try again later."); - } {% if v %} - - - + + + {% endif %}