remove loaned books from books on shelf - fixes BUG-38
This commit is contained in:
2
BUGs
2
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)
|
||||
|
||||
12
main.py
12
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)
|
||||
|
||||
Reference in New Issue
Block a user