fixed ordering by title
This commit is contained in:
17
main.py
17
main.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user