From 2028266ff74aadb69584f564ec61b908cbf0e756 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 5 Jan 2021 11:09:51 +1100 Subject: [PATCH] fixed BUG-12: remove loaned out books from results of search for books to add to a loan --- BUGs | 8 ++++++-- README | 1 - main.py | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/BUGs b/BUGs index b3e90a7..2929721 100644 --- a/BUGs +++ b/BUGs @@ -1,11 +1,15 @@ #### BUGS (next-13) + +### DB/back-end BUG-2: series does not deal with calcd_rating... - (on edit could, recalc as a catch-all, and obviously if we change a single book's rating, we should re-calc) +BUG-13: deleting loan fails with book_loan_link data still existing +### UI not updating after DB change: BUG-3: alter a condition, covertype, etc. and its not in drop-down list (even though db look via index is correct, e.g books.html shows updated covertype) +BUG-7: if you remove a series from a book, it won't appear in the series drop-down if it is the first 'missing' book in that series -- either reset the list, or show all series always? +### ordering of data in UI: BUG-6: author,series, etc. do not have explicit ordering like sub-books... sort of irritating / needs code and DB fix - add/remove authors, and after save they are ordered by author.id, not order of addition (prob. needs book_author_link to have an auth_num) -BUG-7: if you remove a series from a book, it won't appear in the series drop-down if it is the first 'missing' book in that series -- either reset the list, or show all series always? -BUG-12: remove loaned out books from results of search for books to add to a loan diff --git a/README b/README index dcf2e56..ef99d05 100644 --- a/README +++ b/README @@ -55,4 +55,3 @@ TODO-19: icons on wish list, etc.? (not sure I really want them, but if so) TODO-20: ORM all books load is slow - should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....) TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book) - diff --git a/main.py b/main.py index 54508c5..3de473e 100644 --- a/main.py +++ b/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"])