From 3e7dcd66904057eb94fc7c5ad70d8968e8aa77f3 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 26 Jul 2021 19:00:29 +0200 Subject: [PATCH] dfdf --- drama/classes/mix_ins.py | 4 ---- drama/routes/front.py | 4 ++-- drama/routes/posts.py | 6 ++---- drama/routes/votes.py | 4 ++-- drama/templates/submission_banned.html | 2 +- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drama/classes/mix_ins.py b/drama/classes/mix_ins.py index 4d2bd8aa92..85313a7a2a 100644 --- a/drama/classes/mix_ins.py +++ b/drama/classes/mix_ins.py @@ -122,10 +122,6 @@ class Scores: @property #@cache.memoize(timeout=60) def score_percent(self): - # try: - # return int((self.ups/(self.ups+self.downs))*100) - # except ZeroDivisionError: - # return 0 return 101 diff --git a/drama/routes/front.py b/drama/routes/front.py index aa23b51828..930cb9e6bb 100644 --- a/drama/routes/front.py +++ b/drama/routes/front.py @@ -164,8 +164,8 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='' g.db.add(vote) try: g.db.flush() except: g.db.rollback() - post.upvotes = post.ups - post.downvotes = post.downs + post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() + post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() post.views = post.views + random.randint(7,10) g.db.add(post) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 53a6b42b3d..dd260d1809 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -194,8 +194,8 @@ def post_base36id(pid, anything=None, v=None): g.db.add(vote) try: g.db.flush() except: g.db.rollback() - comment.upvotes = comment.ups - comment.downvotes = comment.downs + comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count() + comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count() g.db.add(comment) post._preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)] @@ -971,8 +971,6 @@ def submit_post(v): user = get_account(follow.user_id) send_notification(2360, user, f"@{v.username} has made a new post: [{title}](https://rdrama.net{new_post.permalink})") - new_post.upvotes = new_post.ups - new_post.downvotes = new_post.downs g.db.add(new_post) g.db.commit() diff --git a/drama/routes/votes.py b/drama/routes/votes.py index 18e9ad30bb..e40d628962 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -117,8 +117,8 @@ def api_vote_post(post_id, x, v): g.db.flush() - post.upvotes = g.db.query(Vote).filter_by(comment_id=comment.id, vote_type=1).count() - post.downvotes = g.db.query(Vote).filter_by(comment_id=comment.id, vote_type=-1).count() + post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() + post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() g.db.add(post) return "", 204 diff --git a/drama/templates/submission_banned.html b/drama/templates/submission_banned.html index e4ae781b7a..f330004658 100644 --- a/drama/templates/submission_banned.html +++ b/drama/templates/submission_banned.html @@ -44,7 +44,7 @@ {% endif %} {% endif %} -

Score: +{{p.ups}}/-{{p.downs}}

+

Score: +{{p.upvotes}}/-{{p.downvotes}}

{% endblock %} {% block content %}