def post(self, share_key, comment_id):
shared_file = models.Sharedfile.get_by_share_key(share_key)
user = self.get_current_user_object()
comment = Comment.get("id=%s", comment_id)
if not shared_file or not comment:
raise tornado.web.HTTPError(404)
existing_comment_like = models.CommentLike.get("comment_id = %s and user_id = %s",
comment.id, user.id)
if existing_comment_like:
existing_comment_like.deleted = 1
existing_comment_like.save()
json = self.get_argument("json", False)
if json:
self.set_header("Cache-Control","no-store, no-cache, must-revalidate");
self.set_header("Pragma","no-cache");
self.set_header("Expires", 0);
count = models.CommentLike.where_count("comment_id = %s", comment.id)
return self.write(json_encode({'response':'ok', 'count': count, 'like' : True }))
else:
return self.redirect("/p/%s?salty" % (share_key,))
评论列表
文章目录