From 10f50ecc606a84ead65526f78a9544996f8e6ccd Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 26 May 2018 23:48:59 +0300 Subject: [PATCH] =?utf8?q?Feat(web:books):=20=D0=9F=D0=BE=D0=BA=D0=B0?= =?utf8?q?=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=BF=D0=B8=D1=81?= =?utf8?q?=D0=BE=D0=BA=20=D0=BA=D0=BD=D0=B8=D0=B3=20=D1=81=20=D1=80=D0=B0?= =?utf8?q?=D0=B7=D0=B1=D0=B8=D0=B2=D0=BA=D0=BE=D0=B9=20=D0=BF=D0=BE=20?= =?utf8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B0=D0=BC=20=D0=B8=20=D1=81?= =?utf8?q?=D0=B5=D1=80=D0=B8=D1=8F=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- docs-ru/news.rst | 2 + m_librarian/web/app.py | 10 ++++- m_librarian/web/views/list_books.py | 59 +++++++++++++++------------ m_librarian/web/views/list_books.tmpl | 30 ++++++++------ 4 files changed, 60 insertions(+), 41 deletions(-) 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
-- 2.39.2