created OrderBooks covenience function, then didnt use it elsewhere ;)

This commit is contained in:
2023-07-04 22:21:32 +10:00
parent 3bbe971b92
commit 0d48053a6d

22
main.py
View File

@@ -911,14 +911,7 @@ def rem_parent_books_from_series(pid):
db.session.commit()
return jsonify(success=True)
@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()
RemSubs(books)
def OrderBooks(books):
# because a book can be in multiple series, without any ordering we need to find
# any book that is in a series, then go through each series to find the one with
# the most books in it. THEN we need to get all those books and put them in the
@@ -954,8 +947,19 @@ def books_on_shelf():
ordered_books.append(tmp_b)
processed.append(tmp_b.id)
else:
# book not in a series or a sub-book, so just add this book to the ordered list
# book not in a series and we removed sub-books, so just add this book to the ordered list
ordered_books.append(b)
return ordered_books
@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()
RemSubs(books)
ordered_books=OrderBooks(books)
return render_template("books.html", books=ordered_books, page_title="Books on Shelf", order_by="", show_cols='', hide_cols='' )