fixed undocd BUG, where book sold is parent book in series messing with missing books code

This commit is contained in:
2021-01-09 22:07:00 +11:00
parent 0432f46b20
commit b35d0b0088

11
main.py
View File

@@ -665,8 +665,7 @@ def unrated_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():
def FindMissingBooks():
tmp = db.engine.execute("select s.*, count(bsl.book_num) from book_series_link bsl, series s where bsl.book_num is not null and s.id = bsl.series_id group by s.id order by s.title")
books=[]
sold=Owned.query.filter(Owned.name=='Sold').all()
@@ -680,6 +679,9 @@ def missing_books():
# check to see if the only books in this series are SOLD, if so, there
# are no missing books here, I clearly dont want more of this series
for b in bsl:
print("b={}".format( b ) )
if b.book_num == None:
continue
missing.remove( b.book_num )
tmp_book=Book.query.get(b.book_id)
if tmp_book.owned == sold[0].id:
@@ -689,6 +691,11 @@ def missing_books():
else:
# turn missing from array into string, and strip 0 and last char (the square brackets)
books.append( { 'id': t.id, 'title': t.title, 'num_books': t.num_books, 'missing': str(missing)[1:-1] } )
return books
@app.route("/missing_books", methods=["GET"])
def missing_books():
books=FindMissingBooks()
return render_template("missing.html", books=books )
@app.route("/wishlist", methods=["GET"])