Exemple #1
0
def author_books(author_id, page):
    author = Author.query.get(author_id)
    if not author:
        abort(404)
    books_pager = books_sorted(author.books).paginate(page, ITEMS_PER_PAGE)
    return render_template('books_list.html', author=author,
                           books_pager=books_pager)
Exemple #2
0
def search(page):
    search_type = request.args.get('type', 'books')
    search_term = request.args.get('term', '')
    curr_author_id = request.args.get('curr_author_id')
    if search_type not in ('authors', 'books'):
        search_type = 'books'
    if search_type == 'authors':
        authors = authors_sorted(Author.search_by_last_name(search_term))
        authors_pager = authors.paginate(page, ITEMS_PER_PAGE)
        return render_template(
            'authors_search_results.html',
            authors_pager=authors_pager,
            search_term=search_term,
            search_type=search_type
        )
    elif search_type == 'books':
        books = books_sorted(Book.search_by_title(search_term))
        books_pager = books.paginate(page, ITEMS_PER_PAGE)
        return render_template(
            'books_search_result.html',
            books_pager=books_pager,
            search_term=search_term,
            search_type=search_type,
            curr_author_id=curr_author_id
        )
    assert False, "Uknown search type"
Exemple #3
0
def author_books_other(author_id, page):
    author = Author.query.get(author_id)
    if not author:
        abort(404)
    books = author.books.filter_by(sequence_id=None)
    books_pager = books_sorted(books).paginate(page, ITEMS_PER_PAGE)
    return render_template('books_list.html', author=author,
                           books_pager=books_pager)
Exemple #4
0
def seq_books(seq_id, page):
    books = books_sorted(Book.query.filter_by(sequence_id=seq_id))
    if not books:
        abort(404)
    books_pager = books.paginate(page, ITEMS_PER_PAGE)
    return render_template('seq_books.html', books_pager=books_pager)