X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Fweb%2Fapp.py;h=ef5835b42722abf60382c0815edc820f77a1b2c6;hb=e06c9bf4d4ebce18334d6aa656bc8759241f9219;hp=5d9285e2254912b1f01404d9afaa4cebb41f6489;hpb=ecd2349c26418c8b55ec9e0d17009321b6472236;p=m_librarian.git diff --git a/m_librarian/web/app.py b/m_librarian/web/app.py index 5d9285e..ef5835b 100644 --- a/m_librarian/web/app.py +++ b/m_librarian/web/app.py @@ -70,31 +70,28 @@ def search_authors_post(): @route('/books-by-author//', method='GET') -@cheetah_view('books_by_author.tmpl') +@cheetah_view('list_books.tmpl') def books_by_author(id): use_filters = get_config().getint('filters', 'use_in_books_list', 1) columns = get_config().getlist('columns', 'book', ['title']) + author = Author.get(id) if use_filters: join_expressions = [] join_expressions.append(Book.j.authors) join_expressions.append(Author.q.id == id) books = search_books('full', None, {}, join_expressions, - orderBy=('series', 'ser_no', 'title'), + orderBy=('series', 'ser_no', 'title', '-date'), use_filters=use_filters) - return { - 'author': Author.get(id), - 'books': books, - 'columns': columns, - } else: - return { - 'author': Author.get(id), - 'books': Book.select( - Book.j.authors & (Author.q.id == id), - orderBy=['series', 'ser_no', 'title'], - ), - 'columns': columns, - } + books = Book.select( + Book.j.authors & (Author.q.id == id), + orderBy=['series', 'ser_no', 'title'], + ) + + return { + 'books_by_author': {author.fullname: list(books)}, + 'columns': columns, + } @route('/static/') @@ -156,7 +153,7 @@ def search_books_post(): orderBy=('title',), use_filters=use_filters) books_by_authors = {} for book in books: - author = book.authors[0].fullname + author = book.author1 if author in books_by_authors: books_by_author = books_by_authors[author] else: