diff --git a/files/classes/comment.py b/files/classes/comment.py index 26e5cbdd1..cdc251a70 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -214,10 +214,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): return data - @property - def voted(self): - return self.__dict__.get("_voted") - @property def is_blocking(self): return self.__dict__.get('_is_blocking', 0) diff --git a/files/classes/submission.py b/files/classes/submission.py index 7d2111423..c7c5ed6af 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -149,7 +149,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): # load and tree comments # calling this function with a comment object will do a comment # permalink thing - if "replies" not in self.__dict__ and "_preloaded_comments" in self.__dict__: + if "replies" not in self.__dict__ and "preloaded_comments" in self.__dict__: self.tree_comments(comment=comment) return render_template(template, @@ -172,7 +172,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def tree_comments(self, comment=None, v=None): - comments = self.__dict__.get('_preloaded_comments',[]) + comments = self.__dict__.get('preloaded_comments',[]) if not comments: return @@ -283,8 +283,8 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): if "replies" in self.__dict__: data["replies"]=[x.json_core for x in self.replies] - if "_voted" in self.__dict__: - data["voted"] = self._voted + if "voted" in self.__dict__: + data["voted"] = self.voted return data @@ -293,7 +293,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): @property def voted(self): - return self._voted if "_voted" in self.__dict__ else 0 + return self.voted if "voted" in self.__dict__ else 0 @property def title(self): diff --git a/files/helpers/get.py b/files/helpers/get.py index fa6d4f31f..6498fedca 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -104,7 +104,7 @@ def get_post(i, v=None, graceful=False, **kwargs): if not items and not graceful: abort(404) x = items[0] - x._voted = items[1] or 0 + x.voted = items[1] or 0 x._is_blocking = items[2] or 0 else: items = g.db.query( @@ -154,7 +154,7 @@ def get_posts(pids, v=None): output = [p[0] for p in query] for i in range(len(output)): - output[i]._voted = query[i][1] or 0 + output[i].voted = query[i][1] or 0 output[i]._is_blocking = query[i][2] or 0 output[i]._is_blocked = query[i][3] or 0 else: @@ -190,7 +190,7 @@ def get_comment(i, v=None, graceful=False, **kwargs): vt = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=Comment.id).first() comment._is_blocking = block and block.user_id == v.id comment._is_blocked = block and block.target_id == v.id - comment._voted = vt.vote_type if vt else 0 + comment.voted = vt.vote_type if vt else 0 else: comment = g.db.query(Comment).filter(Comment.id == i).first() @@ -237,7 +237,7 @@ def get_comments(cids, v=None, load_parent=False): for c in comments: comment = c[0] if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): continue - comment._voted = c[1] or 0 + comment.voted = c[1] or 0 comment._is_blocking = c[2] or 0 comment._is_blocked = c[3] or 0 output.append(comment) diff --git a/files/routes/comments.py b/files/routes/comments.py index c8befb0d4..583401651 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -53,7 +53,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if request.headers.get("Authorization"): return {'error': f'This content is not suitable for some users and situations.'} else: render_template("errors/nsfw.html", v=v) - post._preloaded_comments = [comment] + post.preloaded_comments = [comment] # context improver try: context = int(request.args.get("context", 0)) @@ -64,7 +64,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): parent = get_comment(c.parent_comment_id, v=v) - post._preloaded_comments += [parent] + post.preloaded_comments += [parent] c = parent context -= 1 @@ -133,7 +133,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): for c in comments: comment = c[0] if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): continue - comment._voted = c[1] or 0 + comment.voted = c[1] or 0 comment._is_blocking = c[2] or 0 comment._is_blocked = c[3] or 0 output.append(comment) @@ -164,7 +164,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): abort(422) - post._preloaded_comments += output + post.preloaded_comments += output current_ids = [x.id for x in output] diff --git a/files/routes/posts.py b/files/routes/posts.py index 94383bdc5..59fa50dcc 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -125,12 +125,12 @@ def post_id(pid, anything=None, v=None): for c in comments: comment = c[0] if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): continue - comment._voted = c[1] or 0 + comment.voted = c[1] or 0 comment._is_blocking = c[2] or 0 comment._is_blocked = c[3] or 0 output.append(comment) - post._preloaded_comments = output + post.preloaded_comments = output else: comments = g.db.query( @@ -169,7 +169,7 @@ def post_id(pid, anything=None, v=None): 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)] + post.preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)]