fixed BUG-12: remove loaned out books from results of search for books to add to a loan
This commit is contained in:
6
main.py
6
main.py
@@ -230,12 +230,14 @@ book_schema = BookSchema()
|
||||
####################################### ROUTES #######################################
|
||||
@app.route("/search", methods=["POST"])
|
||||
def search():
|
||||
books = Book.query.filter(Book.title.ilike("%{}%".format(request.form['term']))).all()
|
||||
AddSubs(books)
|
||||
if 'InDBox' in request.form:
|
||||
# removes already loaned books from list of books to loan out
|
||||
books = Book.query.outerjoin(Book_Loan_Link).filter(Book.title.ilike("%{}%".format(request.form['term'])),Book_Loan_Link.loan_id==None).all()
|
||||
InDBox=1
|
||||
else:
|
||||
books = Book.query.filter(Book.title.ilike("%{}%".format(request.form['term']))).all()
|
||||
InDBox=0
|
||||
AddSubs(books)
|
||||
return render_template("books.html", books=books, InDBox=InDBox)
|
||||
|
||||
@app.route("/books", methods=["GET"])
|
||||
|
||||
Reference in New Issue
Block a user