Beispiel #1
0
 def GET(self, post_id):
     post_id = int(post_id)
     post = model.Post().view(post_id)
     if post:
         comment = model.Comment(int(post_id))
         comments = comment.quote(comment.list())
         comment_lis = util.comments_to_lis(comments)
         return titled_render(post.title).view(post, comment_lis)
     else:
         raise web.seeother('/')
Beispiel #2
0
 def POST(self, post_id):
     # jQuery+Ajax实现无刷新回帖
     i = web.input()
     cur_user_id = model.User().current_id()
     web.header('Content-Type', 'application/json')
     if cur_user_id:
         comment = model.Comment(int(post_id))
         # 回帖成功:返回"回帖"+"引用贴"信息
         if comment.new(i.content, cur_user_id, i.quote_id):
             comments = comment.quote([comment.last()])
             return json.dumps(util.comments_to_lis(comments))
     # 无权限:返回空
     return json.dumps([])