Fix API for /comment/<cid>, /search/comments.

pull/2/head
Snakes 2022-11-18 15:33:07 -05:00
parent 6f1b9014b4
commit 2c81db79ef
Signed by: Snakes
GPG Key ID: E745A82778055C7E
3 changed files with 15 additions and 15 deletions

View File

@ -30,12 +30,12 @@ class Vote(Base):
@property
@lazy
def json(self):
return {"user_id": self.user_id,
"submission_id":self.submission_id,
"vote_type":self.vote_type,
"user":self.user.json,
"post":self.post.json
}
return {
"user_id": self.user_id,
"submission_id": self.submission_id,
"vote_type": self.vote_type,
"user": self.user.json,
}
class CommentVote(Base):
@ -61,9 +61,9 @@ class CommentVote(Base):
@property
@lazy
def json(self):
return {"user_id": self.user_id,
"submission_id":self.submission_id,
"vote_type":self.vote_type,
"user":self.user.json,
"comment":self.comment.json
}
return {
"user_id": self.user_id,
"submission_id": self.submission_id,
"vote_type": self.vote_type,
"user": self.user.json,
}

View File

@ -73,7 +73,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
execute_shadowban_viewers_and_voters(v, post)
execute_shadowban_viewers_and_voters(v, comment)
if v and v.client: return top_comment.json
if v and v.client: return top_comment.json(db=g.db)
else:
if post.is_banned and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.author_id == v.id)): template = "submission_banned.html"
else: template = "submission.html"
@ -361,7 +361,7 @@ def comment(v):
g.db.flush()
if v.client: return c.json(g.db)
if v.client: return c.json(db=g.db)
return {"comment": render_template("comments.html", v=v, comments=[c])}

View File

@ -268,7 +268,7 @@ def searchcomments(v):
comments = get_comments(ids, v=v)
if v.client: return {"total":total, "data":[x.json for x in comments]}
if v.client: return {"total":total, "data":[x.json(db=g.db) for x in comments]}
return render_template("search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists, standalone=True)