remotes/1693045480750635534/spooky-22
Aevann1 2021-08-08 01:01:07 +02:00
parent f2606b5095
commit 2f1bbd6a43
5 changed files with 16 additions and 20 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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)

View File

@ -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]

View File

@ -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)]