diff --git a/BUGs b/BUGs index 205ab0f..9930448 100644 --- a/BUGs +++ b/BUGs @@ -16,6 +16,4 @@ BUG-36: when creating a book and missing genre BUT also on wish list, it say BUG-37: should allow deleting from 'On Wishlist' as well -BUG-38: books on shelf should not show books on Loan - BUG-39: Loaned to "info box" is below save, not to the left? (or somehow better anyway, it looks pox now) diff --git a/main.py b/main.py index 6701708..6cfb8b6 100644 --- a/main.py +++ b/main.py @@ -951,12 +951,24 @@ def OrderBooks(books): ordered_books.append(b) return ordered_books +def RemLoans(books): + """ Remove any books on loan from list - used for books on shelf view """ + from main import Book_Loan_Link + + loaned_books=Book_Loan_Link.query.all() + for b in loaned_books: + for i, item in enumerate(books): + if item.id == b.book_id: + books.remove(item) + + @app.route("/books_on_shelf", methods=["GET"]) @login_required def books_on_shelf(): # start with all books owned sorted by author, then title, but it includes sub-books, so remove them... books = Book.query.join(Owned).join(Book_Author_Link).join(Author).filter(Owned.name=='Currently Owned').filter(Book_Author_Link.author_num==1).order_by(Author.surname,Author.firstnames,Book.title).all() + RemLoans(books) RemSubs(books) ordered_books=OrderBooks(books)