+
+
+@route('/books-by-author/<id:int>/', method='GET')
+@cheetah_view('books_by_author.tmpl')
+def books_by_author(id):
+ return {
+ 'author': Author.get(id),
+ 'books': Book.select(
+ Book.j.authors & (Author.q.id == id),
+ orderBy=['series', 'ser_no', 'title'],
+ )
+ }
+
+
+@route('/static/<filename:path>')
+def send_static(filename):
+ return static_file(
+ filename, root=os.path.join(
+ os.path.dirname(__file__),
+ 'static'
+ )
+ )
+
+
+@route('/download/', method='POST')
+@cheetah_view('download.tmpl')
+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'Не выбрано книг для сохранения.',
+ }