diff --git a/BUGs b/BUGs
index 0ba58f8..6a79290 100644
--- a/BUGs
+++ b/BUGs
@@ -1,4 +1,4 @@
-#### BUGS (next-16)
+#### BUGS (next-17)
### DB/back-end
BUG-2: series does not deal with calcd_rating...
diff --git a/README b/README
index b8f8772..4272c78 100644
--- a/README
+++ b/README
@@ -30,7 +30,6 @@ sudo docker-compose -f /srv/docker/config/docker-compose.yml up bookdb_web
########################################################### TODOS (next 29):
-TODO-28: make books.html have page_title? and pass in a 'print these cols'... at least for poor ratings, etc. so we can hide dud columns, and show more useful ones
TODO-27: from missing, exclude any series where the only books we have are SOLD
TODO-05: should deleting really just ask if want to mark it as SOLD? IN FACT, make delete button disabled until its sold... (and a tooltip to explain)
TODO-09: show books to buy view / printable
diff --git a/main.py b/main.py
index 9af93ef..5b876f4 100644
--- a/main.py
+++ b/main.py
@@ -231,6 +231,15 @@ def AddSubs(books):
books[index].parent_id = row.book_id
books[index].sub_book_num = row.sub_book_num
+# HACK: Couldn't work out ORM to excluded sub_book self-ref, so using basic python
+# loop to remove sub_books from list
+def RemSubs(books):
+ subs = db.engine.execute ( "select * from book_sub_book_link" )
+ for row in subs:
+ for i, item in enumerate(books):
+ if item.id == row.sub_book_id:
+ books.remove(item)
+
####################################### GLOBALS #######################################
# allow jinja2 to call these python functions directly
app.jinja_env.globals['GetCovertypeById'] = GetCovertypeById
@@ -243,6 +252,7 @@ app.jinja_env.globals['ClearStatus'] = st.ClearMessage
app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks
book_schema = BookSchema()
+books_schema = BookSchema(many=True)
####################################### ROUTES #######################################
@app.route("/search", methods=["POST"])
@@ -647,13 +657,14 @@ def rem_parent_books_from_series(pid):
@app.route("/books_on_shelf", methods=["GET"])
def books_on_shelf():
- books = db.engine.execute("select * from book where id not in ( select sub_book_id from book_sub_book_link ) and owned = (select id from owned where name = 'Currently Owned')")
- return render_template("books.html", books=books )
+ books = Book.query.join(Owned).filter(Owned.name=='Currently Owned').all()
+ RemSubs(books)
+ return render_template("books.html", books=books, page_title="Books on Shelf", order_by="Author(s)", show_cols='', hide_cols='' )
@app.route("/unrated_books", methods=["GET"])
def unrated_books():
- books = db.engine.execute("select * from book where rating = (select id from rating where name = 'Undefined') and owned = (select id from owned where name = 'Currently Owned')")
- return render_template("books.html", books=books )
+ books = Book.query.join(Condition,Owned).filter(Rating.name=='Undefined',Owned.name=='Currently Owned').all()
+ return render_template("books.html", books=books, page_title="Books with no rating", show_cols='Rating', hide_cols='' )
@app.route("/missing_books", methods=["GET"])
def missing_books():
diff --git a/templates/base.html b/templates/base.html
index 5e62e29..260289b 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -122,7 +122,12 @@
{%block script_content %}{% endblock script_content %}