From 7e7450ef339cf29aa9646ee583d64d6261d8ced8 Mon Sep 17 00:00:00 2001 From: Aevann1 <59999695+Aevann1@users.noreply.github.com> Date: Tue, 28 Jun 2022 09:20:29 +0200 Subject: [PATCH 1/3] Made it possible to downvote poll options again for schizocel my beloved --- files/routes/votes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/routes/votes.py b/files/routes/votes.py index dcc0939c2..da2038d15 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -138,7 +138,7 @@ def api_vote_comment(comment_id, new, v): comment = get_comment(comment_id) - if comment.author_id in poll_bots: return {"error": "forbidden."}, 403 + if new == 1 and comment.author_id in poll_bots: return {"error": "forbidden."}, 403 existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none() @@ -287,4 +287,4 @@ def api_vote_choice(comment_id, v): g.db.flush() comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count() g.db.add(comment) - return "", 204 \ No newline at end of file + return "", 204 From 159af40cfe805cfe9755cea99023d631f66dc1e5 Mon Sep 17 00:00:00 2001 From: TLSM Date: Tue, 28 Jun 2022 03:43:16 -0400 Subject: [PATCH 2/3] Fix /bet route not enforcing exclusive votes. --- files/routes/votes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files/routes/votes.py b/files/routes/votes.py index da2038d15..1ff55af04 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -239,8 +239,10 @@ def bet(comment_id, v): vote = request.values.get("vote") comment_id = int(comment_id) comment = get_comment(comment_id) - - existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none() + + option_ids = map(lambda x: x.id, comment.post.bet_options) + existing = g.db.query(CommentVote).filter_by(user_id=v.id) \ + .filter(CommentVote.comment_id.in_(option_ids)).one_or_none() if existing: return "", 204 vote = CommentVote(user_id=v.id, vote_type=1, comment_id=comment.id) From adfad3e8a5dbd24cb44847931025c99678f8d24d Mon Sep 17 00:00:00 2001 From: TLSM Date: Tue, 28 Jun 2022 03:53:33 -0400 Subject: [PATCH 3/3] Swap lottery & random_user nav, and other nav. --- files/templates/header.html | 25 +++--------------------- files/templates/sidebar_Cringetopia.html | 6 +++++- files/templates/sidebar_PCM.html | 6 +++++- files/templates/sidebar_WPD.html | 4 +++- files/templates/sidebar_rDrama.html | 4 +++- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/files/templates/header.html b/files/templates/header.html index ba5cdad72..8b1e097fd 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -89,15 +89,7 @@ {% endif %} - {% if v and v.can_gamble and LOTTERY_ENABLED %} - - - - - - {% endif %} +