def add(book_id):
form = CommentForm()
the_book = Book.query.get_or_404(book_id)
if the_book.hidden and not current_user.is_administrator():
abort(404)
if form.validate_on_submit():
the_comment = Comment(user=current_user, book=the_book, comment=form.comment.data)
db.session.add(the_comment)
db.session.commit()
flash(u'???????', 'success')
return redirect(request.args.get('next') or url_for('book.detail', book_id=book_id))
评论列表
文章目录