Beispiel #1
0
def add_book():
    title = 'Add Book'
    book = model.get_book(None)  # blank book obj for form

    return render_template('books/add.html', book=book, new=True,
                           series=request.args.get('series'),
                           series_seq=request.args.get('series_seq'),
                           title=title)
Beispiel #2
0
def edit_book(id):
    book = model.get_book(id)

    if book:
        if not model.user_can_modify_book(book, current_user):
            abort(403)
        title = u'{} | Edit'.format(book.title)

        return render_template('books/edit.html', book=book, new=False, title=title)
Beispiel #3
0
def download_book(id):
    book = model.get_book(id)

    if not model.user_can_download_book(book, current_user):
        abort(403)

    response = Response()
    # todo: there has to be a better way to do this.
    # book_upload_set.url doesn't generate the right URL for nginx
    response.headers['X-Accel-Redirect'] = app.config['UPLOADS_DEFAULT_URL'] + 'library/' + book.filename
    response.headers['Content-Disposition'] = 'attachment; filename="%s"' % book.filename
    return response
Beispiel #4
0
def write_book_meta(id):
    book = model.get_book(id)
    book.write_meta()
    flash('Saved file metadata', 'success')
    return redirect(url_for('edit_book', id=id))