def post(id): form = CommentsForm(request.form) post = PostService.get_one(id) cs = CommentService.get_comments(id) if request.method == "GET": return render_template('web/post.html', form=form, post=post, cs=cs) post_id = int(id) name = form.name.data email = form.email.data comments = form.comments.data try: comment = CommentService.add_comment(post_id=post_id, name=name, email=email, comments=comments) flash('Add a comment successful!') except: flash('Failed to add a comment!') return render_template('web/post.html', form=form, post=post, cs=cs)
def post(id): form = CommentsForm(request.form) post = PostService.get_one(id) cs = CommentService.get_comments(id) if request.method == "GET": return render_template('web/post.html', form=form, post=post, cs=cs) post_id = int(id) name = form.name.data email = form.email.data comments = form.comments.data try: comment = CommentService.add_comment( post_id=post_id, name=name, email=email, comments=comments) flash('Add a comment successful!') except: flash('Failed to add a comment!') return render_template('web/post.html', form=form, post=post, cs=cs)
def post(id): post = PostService.get_one(id) cs = CommentService.get_comments(id) return render_template('admin/post.html', post=post, cs=cs)
def comments_count(post_id): comments_count = CommentService.get_comments_count(post_id) return jsonify_with_data(APIError.OK, comments_count=comments_count)