From eb537484801494d127e44aa2bd6735fa4064d508 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 04:41:14 +0200 Subject: [PATCH 1/8] fdsfsd --- files/classes/submission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 0fb9c1abfd..6bb0fece13 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -87,7 +87,7 @@ class Submission(Base): @property @lazy def bet_options(self): - return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOBETTER_ID, level=1).order_by(Comment.upvotes.desc()) + return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOBETTER_ID, level=1) def total_poll_voted(self, v): if v: From 5dbcf1009e41f884154976995aa61a3c3a9ab3dc Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 04:44:13 +0200 Subject: [PATCH 2/8] fsdfds --- files/templates/submission.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/templates/submission.html b/files/templates/submission.html index eadf02e104..98a16ff600 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -23,6 +23,7 @@ scoretext.textContent = score + 1; post('/bet/' + cid); document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200; + document.getElementById("span-{{c.id}}").classList.add('bet_voted') } @@ -433,7 +434,7 @@ {% endfor %} {% for c in p.bet_options %} - 200) or p.total_bet_voted(v) %}disabled{% endif %} type="radio" id="{{c.id}}" onchange="bet_vote('{{c.id}}')"> + 200) or p.total_bet_voted(v) %}disabled{% endif %} type="radio" id="{{c.id}}" onchange="bet_vote('{{c.id}}')">
{% endfor %} From 43f135388d35183534188c4a901091957090e850 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 04:45:11 +0200 Subject: [PATCH 3/8] sdffds --- files/templates/submission.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/submission.html b/files/templates/submission.html index 98a16ff600..4bf0797ecf 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -23,7 +23,7 @@ scoretext.textContent = score + 1; post('/bet/' + cid); document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200; - document.getElementById("span-{{c.id}}").classList.add('bet_voted') + document.getElementById(`span-${cid}`).classList.add('bet_voted') } From b5cd384cb657d6d91b3cb324ed684213e1f47f58 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 04:47:14 +0200 Subject: [PATCH 4/8] fsdfsd --- files/classes/comment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 0c427098ab..1eeb942698 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -7,7 +7,7 @@ from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base from files.classes.votes import CommentVote -from files.helpers.const import AUTOPOLLER_ID, censor_slurs +from files.helpers.const import AUTOPOLLER_ID, AUTOBETTER_ID, censor_slurs from files.helpers.lazy import lazy from .flags import CommentFlag from random import randint From 99638c65566aa8ce715f826100f971852012d385 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 04:54:27 +0200 Subject: [PATCH 5/8] fsdfds --- files/classes/comment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 1eeb942698..d98f441836 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -187,7 +187,7 @@ class Comment(Base): def replies(self): r = self.__dict__.get("replies", None) if r: r = [x for x in r if not x.author.shadowbanned] - if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID))], key=lambda x: x.score, reverse=True) + if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID)], key=lambda x: x.score, reverse=True) return r @replies.setter @@ -205,7 +205,7 @@ class Comment(Base): @property def replies3(self): r = self.__dict__.get("replies", None) - if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID))], key=lambda x: x.score, reverse=True) + if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID)], key=lambda x: x.score, reverse=True) return r @property From 4a881347ad99d7b284e74da860ebbc4411b2fb7d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 04:58:04 +0200 Subject: [PATCH 6/8] fdsfds --- files/classes/submission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 6bb0fece13..01da808cc3 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -91,7 +91,7 @@ class Submission(Base): def total_poll_voted(self, v): if v: - for option in self.options + self.bet_options: + for option in self.options: if option.poll_voted(v): return True return False From e8c0ce18a239ccc33dcdb5f8f314e84f091347f2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 05:07:51 +0200 Subject: [PATCH 7/8] sfdfsd --- files/classes/votes.py | 2 +- files/routes/admin.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/files/classes/votes.py b/files/classes/votes.py index 2f42956b0b..22f431c640 100644 --- a/files/classes/votes.py +++ b/files/classes/votes.py @@ -56,7 +56,7 @@ class CommentVote(Base): app_id = Column(Integer, ForeignKey("oauth_apps.id")) real = Column(Boolean, default=True) - user = relationship("User", lazy="subquery", viewonly=True) + user = relationship("User", lazy="subquery") comment = relationship("Comment", lazy="subquery", viewonly=True) def __init__(self, *args, **kwargs): diff --git a/files/routes/admin.py b/files/routes/admin.py index d550c971f9..16dd749cc8 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -21,6 +21,22 @@ SITE_NAME = environ.get("SITE_NAME", "").strip() if SITE_NAME == 'PCM': cc = "splash mountain" else: cc = "country club" +@app.get("/distribute/") +@admin_level_required(2) +def distribute(v, cid): + votes = g.db.query(CommentVote).filter_by(comment_id=cid) + autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first() + coinsperperson = int(autobetter.coins / votes.count()) + for vote in votes: + u = vote.user + u.coins += coinsperperson + g.db.add(u) + + autobetter.coins = 0 + g.db.add(autobetter) + g.db.commit() + return str(coinsperperson) + @app.get("/marseys") @auth_desired def marseys(v): From 8d1de6e6282bd6d0b88b5dc6521bcfd3783c31a5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 11 Dec 2021 05:18:14 +0200 Subject: [PATCH 8/8] fdsfds --- files/routes/admin.py | 2 ++ files/templates/submission.html | 20 +++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index 16dd749cc8..7b109122c1 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -24,6 +24,8 @@ else: cc = "country club" @app.get("/distribute/") @admin_level_required(2) def distribute(v, cid): + try: int(cid) + except: abort(400) votes = g.db.query(CommentVote).filter_by(comment_id=cid) autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first() coinsperperson = int(autobetter.coins / votes.count()) diff --git a/files/templates/submission.html b/files/templates/submission.html index 4bf0797ecf..4ea6872bcb 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -13,20 +13,6 @@ {% block title %} - - {% if p.award_count("train") %}