Fix API for /comment/<cid>, /search/comments.
parent
6f1b9014b4
commit
2c81db79ef
|
@ -30,12 +30,12 @@ class Vote(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
return {"user_id": self.user_id,
|
return {
|
||||||
"submission_id":self.submission_id,
|
"user_id": self.user_id,
|
||||||
"vote_type":self.vote_type,
|
"submission_id": self.submission_id,
|
||||||
"user":self.user.json,
|
"vote_type": self.vote_type,
|
||||||
"post":self.post.json
|
"user": self.user.json,
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommentVote(Base):
|
class CommentVote(Base):
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ class CommentVote(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
return {"user_id": self.user_id,
|
return {
|
||||||
"submission_id":self.submission_id,
|
"user_id": self.user_id,
|
||||||
"vote_type":self.vote_type,
|
"submission_id": self.submission_id,
|
||||||
"user":self.user.json,
|
"vote_type": self.vote_type,
|
||||||
"comment":self.comment.json
|
"user": self.user.json,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, post)
|
||||||
execute_shadowban_viewers_and_voters(v, comment)
|
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:
|
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"
|
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"
|
else: template = "submission.html"
|
||||||
|
@ -361,7 +361,7 @@ def comment(v):
|
||||||
|
|
||||||
g.db.flush()
|
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])}
|
return {"comment": render_template("comments.html", v=v, comments=[c])}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ def searchcomments(v):
|
||||||
|
|
||||||
comments = get_comments(ids, v=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)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue