Exemplo n.º 1
0
def delete():

    if request.method == 'POST':
        data = request.json
        print(data)

        try:
            PostService.delete_post(data['post_id'])
            CommentService.delete_comments(data['post_id'])
        except Exception as e:
            print(e)
            return json.dumps({'has_error':True, 'message':"删除错误"})

        return jsonify(success=True, message="删除成功" )
Exemplo n.º 2
0
def showComments():

    if request.method == 'POST':
        data = request.json

        try:
            comments = CommentService.get_comments(post_id=data['id'])
            count = CommentService.get_comments_count(post_id=data['id'])
        except:
            return json.dumps({'has_error':True, 'message':"查询出错"})


        if not count:
            return jsonify(success=True, count=0, message="没有评论")
        else:
            return  jsonify(success=True, count=count, info=comments)
Exemplo n.º 3
0
def post(id):
    post = PostService.get_one(id)
    comment = CommentService.get_comments(id)

    return render_template('admin/posts.html', post=post, comment=comment)