From: Oleg Broytman Date: Fri, 25 May 2018 02:05:18 +0000 (+0300) Subject: Feat(web): Загружать выбранный список книг X-Git-Tag: 0.1.3~1 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=4769d45b4b0f30206b7193c47e556807b771f1e8;p=m_librarian.git Feat(web): Загружать выбранный список книг --- 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

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