def del_comment(comment_id): if g.user_id: comment = Comment.objects(id=comment_id).first() comment.pin.update(inc__comments_count=-1) comment.delete() return ('del comment success', 200) return ('del comment session timeout', 400)
def comments_user(user_id, page_num): if g.user_id: limit = 5 start = (page_num - 1) * limit end = page_num * limit comments = Comment.objects(author=user_id)[start:end].order_by('-create_at') res_data = comments_pack(comments) return (json.dumps(res_data), 200) return ('comments mine session timeout', 400)