diff --git a/BUGs b/BUGs index dc2d2bb..62ea312 100644 --- a/BUGs +++ b/BUGs @@ -8,5 +8,3 @@ BUG-46: search (and really all books.html usage), don't deal with sub books (so the code I wrote for author//books) and use that for search for example - test with search for 'dune' - also test with authors book list for frank herbert - -BUG-47: books on shelf ordering is not working (prod data only?) diff --git a/main.py b/main.py index 9b2bc11..2199e04 100644 --- a/main.py +++ b/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/", methods=["GET", "POST"]) @login_required diff --git a/templates/books.html b/templates/books.html index 1aae003..8e401d7 100644 --- a/templates/books.html +++ b/templates/books.html @@ -50,7 +50,7 @@ {% if 'Condition' not in hide_cols %} {% set cond = GetConditionById(book.condition) %} {% if cond == "N/A" %} - N/A + N/A {% else %} {% if cond == "Good" %}