views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:BookLibrary 作者: hufan-akari 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号