-def book_list(request, filters=None, template_name='catalogue/book_list.html',
- nav_template_name='catalogue/snippets/book_list_nav.html',
- list_template_name='catalogue/snippets/book_list.html'):
- """ generates a listing of all books, optionally filtered """
- books_by_author, orphans, books_by_parent = Book.book_list(filters)
- books_nav = OrderedDict()
- for tag in books_by_author:
- if books_by_author[tag]:
- books_nav.setdefault(tag.sort_key[0], []).append(tag)
- return render(request, template_name, {
- 'rendered_nav': render_to_string(nav_template_name, {'books_nav': books_nav}),
- 'rendered_book_list': render_to_string(list_template_name, {
- 'books_by_author': books_by_author,
- 'orphans': orphans,
- 'books_by_parent': books_by_parent,
- })
- })
-
-