From: Oleg Broytman Date: Sat, 26 May 2018 20:48:59 +0000 (+0300) Subject: Feat(web:books): Показывать список книг с разбивкой по авторам и сериям X-Git-Tag: 0.1.4~18 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=10f50ecc606a84ead65526f78a9544996f8e6ccd;p=m_librarian.git Feat(web:books): Показывать список книг с разбивкой по авторам и сериям --- diff --git a/docs-ru/news.rst b/docs-ru/news.rst index 79f2447..bdd5999 100644 --- a/docs-ru/news.rst +++ b/docs-ru/news.rst @@ -6,6 +6,8 @@ Version 0.1.4 (2018-05-??) * Поиск по названиям книг. +* Показывать список найденных книг с разбивкой по авторам и сериям. + Version 0.1.3 (2018-05-25) -------------------------- diff --git a/m_librarian/web/app.py b/m_librarian/web/app.py index 19fca6c..3ca8d4f 100644 --- a/m_librarian/web/app.py +++ b/m_librarian/web/app.py @@ -131,8 +131,16 @@ def search_books_post(): case_sensitive = _guess_case_sensitivity(value) books = search_books(search_type, case_sensitive, {'title': value}, None, orderBy=('title',)) + books_by_authors = {} + for book in books: + author = book.authors[0].fullname + 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) return { - 'books': list(books), + 'books_by_author': books_by_authors, 'search_books': value, 'search_type': search_type, 'case_sensitive': case_sensitive, diff --git a/m_librarian/web/views/list_books.py b/m_librarian/web/views/list_books.py index 73af92b..01fcda4 100644 --- a/m_librarian/web/views/list_books.py +++ b/m_librarian/web/views/list_books.py @@ -36,10 +36,10 @@ VFN=valueForName currentTime=time.time __CHEETAH_version__ = '3.1.0' __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1) -__CHEETAH_genTime__ = 1527354802.495612 -__CHEETAH_genTimestamp__ = 'Sat May 26 20:13:22 2018' +__CHEETAH_genTime__ = 1527367605.801202 +__CHEETAH_genTimestamp__ = 'Sat May 26 23:46:45 2018' __CHEETAH_src__ = 'list_books.tmpl' -__CHEETAH_srcLastModified__ = 'Sat May 26 20:13:18 2018' +__CHEETAH_srcLastModified__ = 'Sat May 26 23:46:44 2018' __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine' if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple: @@ -93,36 +93,41 @@ class list_books(layout): write(u''' ''') - if VFFSL(SL,"books",True): # generated from line 8, col 1 + if VFFSL(SL,"books_by_author",True): # generated from line 8, col 1 write(u'''
@@ -132,7 +137,7 @@ class list_books(layout):
''') - else: # generated from line 36, col 1 + else: # generated from line 40, col 1 write(u'''

\u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438!

''') diff --git a/m_librarian/web/views/list_books.tmpl b/m_librarian/web/views/list_books.tmpl index 9566e89..cab1e1d 100644 --- a/m_librarian/web/views/list_books.tmpl +++ b/m_librarian/web/views/list_books.tmpl @@ -5,26 +5,30 @@ #def body

$title

-#if $books +#if $books_by_author