|
|
@ -136,7 +136,7 @@ def edit_book_by_id(id): |
|
|
|
if user_form.validate_on_submit(): |
|
|
|
# on submit, check fields |
|
|
|
title = user_form.title.data |
|
|
|
input_authors = user_form.author.data |
|
|
|
input_authors = user_form.author.data |
|
|
|
category = user_form.category.data |
|
|
|
year_published = user_form.year_published.data |
|
|
|
if year_published=="": |
|
|
@ -336,6 +336,17 @@ def edit_stack_by_id(id): |
|
|
|
return redirect(url_for('show_stack_by_id', id=id)) |
|
|
|
return render_template('edit_stack_detail.html', stack=stack, form=form) |
|
|
|
|
|
|
|
@app.route('/stacks/<int:stackid>/remove/<int:bookid>', methods=['POST', 'GET']) |
|
|
|
def remove_from_stack(bookid, stackid): |
|
|
|
book = Book.query.get(bookid) |
|
|
|
stack = Stack.query.get(stackid) |
|
|
|
if book not in stack.books: |
|
|
|
return render_template('show_book_detail.html', book=book) |
|
|
|
stack.books.remove(book) |
|
|
|
db.session.commit() |
|
|
|
return render_template('show_book_detail.html', book=book) |
|
|
|
|
|
|
|
|
|
|
|
## search |
|
|
|
|
|
|
|
@app.route('/books', methods= ['POST','GET']) |
|
|
@ -383,7 +394,7 @@ def search_results(searchtype, query): |
|
|
|
|
|
|
|
count = results.count() |
|
|
|
whole = Book.query.count() |
|
|
|
percentage = float(count / whole * 100) |
|
|
|
percentage = float(count / whole * 100) |
|
|
|
|
|
|
|
if search.listview.data: |
|
|
|
return render_template('results.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage) |
|
|
@ -395,7 +406,7 @@ def search_results(searchtype, query): |
|
|
|
query = search.search.data |
|
|
|
results = [] |
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data))) |
|
|
|
|
|
|
|
|
|
|
|
return render_template('results.html', form=search, books=results, books_all=random_order, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage) |
|
|
|
|
|
|
|
|
|
|
|