X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Fweb%2Fapp.py;h=ef5835b42722abf60382c0815edc820f77a1b2c6;hb=e06c9bf4d4ebce18334d6aa656bc8759241f9219;hp=42c5c5a632bee899df2105b1be5c214cd453557c;hpb=63bb5df8cf2595bbe106031911666fb7061a03aa;p=m_librarian.git diff --git a/m_librarian/web/app.py b/m_librarian/web/app.py index 42c5c5a..ef5835b 100644 --- a/m_librarian/web/app.py +++ b/m_librarian/web/app.py @@ -59,37 +59,39 @@ def search_authors_post(): )] authors = search_authors(search_type, case_sensitive, {}, expressions, orderBy=('surname', 'name', 'misc_name')) + columns = get_config().getlist('columns', 'author', ['fullname']) return { 'authors': list(authors), 'search_authors': value, 'search_type': search_type, 'case_sensitive': case_sensitive, + 'columns': columns, } @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, - } else: - return { - 'author': Author.get(id), - 'books': Book.select( - Book.j.authors & (Author.q.id == id), - orderBy=['series', 'ser_no', 'title'], - ) - } + 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/') @@ -151,15 +153,17 @@ 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: books_by_author = books_by_authors[author] = [] books_by_author.append(book) + columns = get_config().getlist('columns', 'book', ['title']) return { 'books_by_author': books_by_authors, 'search_books': value, 'search_type': search_type, 'case_sensitive': case_sensitive, + 'columns': columns, }