Exemplo n.º 1
0
def book(bid):
    is_faved = False
    if not current_user.is_anonymous():
        is_faved = Favourite.is_faved(current_user.id, bid)

    book = Book.get(bid)
    if not book:
        abort(404)
    chapters = Chapter.query.filter_by(book_id=bid)
    last_twelve_chapters = chapters.order_by(Chapter.id.desc()).limit(12)
    first_six_chapters = chapters.limit(6).all()
    first_six_chapters.reverse()
    return render_template('book.html', **locals())