X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Fweb%2Fapp.py;h=31289b8d4f510652ecf046388565fe0cfdcde996;hb=bb78bdc67ee559bd77f7e06e95902930c5410471;hp=5d9285e2254912b1f01404d9afaa4cebb41f6489;hpb=ecd2349c26418c8b55ec9e0d17009321b6472236;p=m_librarian.git diff --git a/m_librarian/web/app.py b/m_librarian/web/app.py index 5d9285e..31289b8 100644 --- a/m_librarian/web/app.py +++ b/m_librarian/web/app.py @@ -69,32 +69,29 @@ def search_authors_post(): } -@route('/books-by-author//', method='GET') -@cheetah_view('books_by_author.tmpl') -def books_by_author(id): +@route('/books-by-author//', method='GET') +@cheetah_view('list_books.tmpl') +def books_by_author(aid): use_filters = get_config().getint('filters', 'use_in_books_list', 1) columns = get_config().getlist('columns', 'book', ['title']) + author = Author.get(aid) if use_filters: join_expressions = [] join_expressions.append(Book.j.authors) - join_expressions.append(Author.q.id == id) + join_expressions.append(Author.q.id == aid) 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 == aid), + orderBy=['series', 'ser_no', 'title'], + ) + + return { + 'books_by_author': {author.fullname: list(books)}, + 'columns': columns, + } @route('/static/') @@ -110,11 +107,16 @@ def send_static(filename): @route('/download/', method='POST') @cheetah_view('download.tmpl') def download_books(): - books_ids = request.forms.getall('books') + books_ids = [] + form = request.forms + for k in form: + if k.split('_')[-1] == 'books': + for bid in form.getall(k): + books_ids.append(bid) download_path = get_config().getpath('download', 'path') if books_ids: - for id in books_ids: - book = Book.get(int(id)) + for bid in books_ids: + book = Book.get(int(bid)) download(book, download_path) return { 'message': u'Книги сохранены.', @@ -156,7 +158,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: