From 4769d45b4b0f30206b7193c47e556807b771f1e8 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 25 May 2018 05:05:18 +0300 Subject: [PATCH] =?utf8?q?Feat(web):=20=D0=97=D0=B0=D0=B3=D1=80=D1=83?= =?utf8?q?=D0=B6=D0=B0=D1=82=D1=8C=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD?= =?utf8?q?=D0=BD=D1=8B=D0=B9=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20?= =?utf8?q?=D0=BA=D0=BD=D0=B8=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- m_librarian/web/app.py | 22 +++++++---- m_librarian/web/views/books_by_author.py | 43 ++++++++++++---------- m_librarian/web/views/books_by_author.tmpl | 9 ++++- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/m_librarian/web/app.py b/m_librarian/web/app.py index 7032825..2296d27 100644 --- a/m_librarian/web/app.py +++ b/m_librarian/web/app.py @@ -87,11 +87,19 @@ def send_static(filename): ) -@route('/download//', method='GET') +@route('/download/', method='POST') @cheetah_view('download.tmpl') -def download_book(id): - book = Book.get(id) - download(book, get_config().get('download', 'path')) - return { - 'message': u'Книга сохранена', - } +def download_books(): + books_ids = request.forms.getall('books') + download_path = get_config().get('download', 'path') + if books_ids: + for id in books_ids: + book = Book.get(int(id)) + download(book, download_path) + return { + 'message': u'Книги сохранены.', + } + else: + return { + 'message': u'Не выбрано книг для сохранения.', + } diff --git a/m_librarian/web/views/books_by_author.py b/m_librarian/web/views/books_by_author.py index c0e2ab8..6d53996 100644 --- a/m_librarian/web/views/books_by_author.py +++ b/m_librarian/web/views/books_by_author.py @@ -36,10 +36,10 @@ VFN=valueForName currentTime=time.time __CHEETAH_version__ = '3.1.0' __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1) -__CHEETAH_genTime__ = 1527213181.482462 -__CHEETAH_genTimestamp__ = 'Fri May 25 04:53:01 2018' +__CHEETAH_genTime__ = 1527213308.313682 +__CHEETAH_genTimestamp__ = 'Fri May 25 04:55:08 2018' __CHEETAH_src__ = 'books_by_author.tmpl' -__CHEETAH_srcLastModified__ = 'Fri May 25 04:52:59 2018' +__CHEETAH_srcLastModified__ = 'Fri May 25 04:55:05 2018' __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine' if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple: @@ -97,40 +97,45 @@ class books_by_author(layout): ''') if VFFSL(SL,"books",True): # generated from line 8, col 1 - write(u'''
- ''') series = None - for book in VFFSL(SL,"books",True): # generated from line 12, col 3 - if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 13, col 3 - if VFFSL(SL,"series",True) is not None: # generated from line 14, col 3 + for book in VFFSL(SL,"books",True): # generated from line 13, col 3 + if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 14, col 3 + if VFFSL(SL,"series",True) is not None: # generated from line 15, col 3 write(u''' ''') series = VFFSL(SL,"book.series",True) write(u''' ''') write(u''' ''') write(u''' + +
+ +
''') - else: # generated from line 31, col 1 + else: # generated from line 36, 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/books_by_author.tmpl b/m_librarian/web/views/books_by_author.tmpl index 668e445..bdd694e 100644 --- a/m_librarian/web/views/books_by_author.tmpl +++ b/m_librarian/web/views/books_by_author.tmpl @@ -6,8 +6,9 @@

$title $author.fullname

#if $books -
- #set $series = None #for $book in $books #if $book.series != $series @@ -27,6 +28,10 @@ $cgi.escape($series, 1)#slurp #end for + +
+ +
#else

Не найдено ни одной книги!

-- 2.39.5