sneed
This commit is contained in:
parent
fc1af6c375
commit
d309ac35ae
5 changed files with 16 additions and 20 deletions
|
@ -214,10 +214,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
|
||||||
def voted(self):
|
|
||||||
return self.__dict__.get("_voted")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_blocking(self):
|
def is_blocking(self):
|
||||||
return self.__dict__.get('_is_blocking', 0)
|
return self.__dict__.get('_is_blocking', 0)
|
||||||
|
|
|
@ -149,7 +149,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
# load and tree comments
|
# load and tree comments
|
||||||
# calling this function with a comment object will do a comment
|
# calling this function with a comment object will do a comment
|
||||||
# permalink thing
|
# 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)
|
self.tree_comments(comment=comment)
|
||||||
|
|
||||||
return render_template(template,
|
return render_template(template,
|
||||||
|
@ -172,7 +172,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
|
|
||||||
def tree_comments(self, comment=None, v=None):
|
def tree_comments(self, comment=None, v=None):
|
||||||
|
|
||||||
comments = self.__dict__.get('_preloaded_comments',[])
|
comments = self.__dict__.get('preloaded_comments',[])
|
||||||
if not comments:
|
if not comments:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -283,8 +283,8 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
if "replies" in self.__dict__:
|
if "replies" in self.__dict__:
|
||||||
data["replies"]=[x.json_core for x in self.replies]
|
data["replies"]=[x.json_core for x in self.replies]
|
||||||
|
|
||||||
if "_voted" in self.__dict__:
|
if "voted" in self.__dict__:
|
||||||
data["voted"] = self._voted
|
data["voted"] = self.voted
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def voted(self):
|
def voted(self):
|
||||||
return self._voted if "_voted" in self.__dict__ else 0
|
return self.voted if "voted" in self.__dict__ else 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def title(self):
|
def title(self):
|
||||||
|
|
|
@ -104,7 +104,7 @@ def get_post(i, v=None, graceful=False, **kwargs):
|
||||||
if not items and not graceful:
|
if not items and not graceful:
|
||||||
abort(404)
|
abort(404)
|
||||||
x = items[0]
|
x = items[0]
|
||||||
x._voted = items[1] or 0
|
x.voted = items[1] or 0
|
||||||
x._is_blocking = items[2] or 0
|
x._is_blocking = items[2] or 0
|
||||||
else:
|
else:
|
||||||
items = g.db.query(
|
items = g.db.query(
|
||||||
|
@ -154,7 +154,7 @@ def get_posts(pids, v=None):
|
||||||
|
|
||||||
output = [p[0] for p in query]
|
output = [p[0] for p in query]
|
||||||
for i in range(len(output)):
|
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_blocking = query[i][2] or 0
|
||||||
output[i]._is_blocked = query[i][3] or 0
|
output[i]._is_blocked = query[i][3] or 0
|
||||||
else:
|
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()
|
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_blocking = block and block.user_id == v.id
|
||||||
comment._is_blocked = block and block.target_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:
|
else:
|
||||||
comment = g.db.query(Comment).filter(Comment.id == i).first()
|
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:
|
for c in comments:
|
||||||
comment = c[0]
|
comment = c[0]
|
||||||
if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): continue
|
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_blocking = c[2] or 0
|
||||||
comment._is_blocked = c[3] or 0
|
comment._is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
|
@ -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.'}
|
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)
|
else: render_template("errors/nsfw.html", v=v)
|
||||||
|
|
||||||
post._preloaded_comments = [comment]
|
post.preloaded_comments = [comment]
|
||||||
|
|
||||||
# context improver
|
# context improver
|
||||||
try: context = int(request.args.get("context", 0))
|
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)
|
parent = get_comment(c.parent_comment_id, v=v)
|
||||||
|
|
||||||
post._preloaded_comments += [parent]
|
post.preloaded_comments += [parent]
|
||||||
|
|
||||||
c = parent
|
c = parent
|
||||||
context -= 1
|
context -= 1
|
||||||
|
@ -133,7 +133,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
for c in comments:
|
for c in comments:
|
||||||
comment = c[0]
|
comment = c[0]
|
||||||
if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): continue
|
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_blocking = c[2] or 0
|
||||||
comment._is_blocked = c[3] or 0
|
comment._is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
@ -164,7 +164,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
abort(422)
|
abort(422)
|
||||||
|
|
||||||
|
|
||||||
post._preloaded_comments += output
|
post.preloaded_comments += output
|
||||||
|
|
||||||
current_ids = [x.id for x in output]
|
current_ids = [x.id for x in output]
|
||||||
|
|
||||||
|
|
|
@ -125,12 +125,12 @@ def post_id(pid, anything=None, v=None):
|
||||||
for c in comments:
|
for c in comments:
|
||||||
comment = c[0]
|
comment = c[0]
|
||||||
if comment.author and comment.author.shadowbanned and not (v and v.id == comment.author_id): continue
|
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_blocking = c[2] or 0
|
||||||
comment._is_blocked = c[3] or 0
|
comment._is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
post._preloaded_comments = output
|
post.preloaded_comments = output
|
||||||
|
|
||||||
else:
|
else:
|
||||||
comments = g.db.query(
|
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()
|
comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count()
|
||||||
g.db.add(comment)
|
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)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue