fixed ordering by title

This commit is contained in:
2023-10-02 19:39:34 +11:00
parent 668a7066e0
commit 5b43826006
3 changed files with 15 additions and 6 deletions

17
main.py
View File

@@ -402,9 +402,20 @@ def search():
@app.route("/books", methods=["GET"])
@login_required
def books():
books = Book.query.all()
AddSubs(books)
return render_template("books.html", books=books )
books = Book.query.order_by(Book.title).all()
# okay remove subs for now (so only real books are in list)
RemSubs(books)
# ordered books will be each real book, but if it has any subs, add them back in (but now in the right order/spot)
ordered_books=[]
for b in books:
ordered_books.append(b)
subs=db.session.execute( text( f"select * from book_sub_book_link where book_id = {b.id}" ) )
for row in subs:
s=Book.query.get(row.sub_book_id)
ordered_books.append(s)
# now get the parent linkages back in so it indents in the front-end html
AddSubs(ordered_books)
return render_template("books.html", books=ordered_books )
@app.route("/books_for_loan/<id>", methods=["GET", "POST"])
@login_required