|
|
@ -200,6 +200,17 @@ def edit_book_by_id(id):
|
|
|
|
@app.route('/add-book', methods=['POST', 'GET'])
|
|
|
|
@app.route('/add-book', methods=['POST', 'GET'])
|
|
|
|
def add_book():
|
|
|
|
def add_book():
|
|
|
|
upload_form = UploadForm()
|
|
|
|
upload_form = UploadForm()
|
|
|
|
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
|
|
|
|
books_all = len(allbooks)
|
|
|
|
|
|
|
|
allauthors = db.session.query(Author).all()
|
|
|
|
|
|
|
|
authors_all = len(allauthors)
|
|
|
|
|
|
|
|
stacks_all = [s.stack_name for s in db.session.query(Stack.stack_name)]
|
|
|
|
|
|
|
|
categories = [r.category for r in db.session.query(Book.category).distinct()]
|
|
|
|
|
|
|
|
allpotential = db.session.query(Book).filter(Book.file.contains('potential.pdf')).all()
|
|
|
|
|
|
|
|
books_potential = len(allpotential)
|
|
|
|
|
|
|
|
earliest = db.session.query(func.min(Book.year_published)).scalar()
|
|
|
|
|
|
|
|
latest = db.session.query(func.max(Book.year_published)).scalar()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
if upload_form.validate_on_submit():
|
|
|
|
if upload_form.validate_on_submit():
|
|
|
@ -268,7 +279,7 @@ def add_book():
|
|
|
|
return redirect(url_for('show_books'))
|
|
|
|
return redirect(url_for('show_books'))
|
|
|
|
|
|
|
|
|
|
|
|
flash_errors(upload_form)
|
|
|
|
flash_errors(upload_form)
|
|
|
|
return render_template('add_book.html', form=upload_form)
|
|
|
|
return render_template('add_book.html', form=upload_form, books_all=books_all, authors_all=authors_all, categories=categories, stacks_all=stacks_all, books_potential=books_potential, earliest=earliest, latest=latest)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Flash errors from the form if validation fails
|
|
|
|
# Flash errors from the form if validation fails
|
|
|
|