remove loaned books from books on shelf - fixes BUG-38
This commit is contained in:
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