diff --git a/README b/README index 4272c78..627f354 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-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 5b876f4..407d039 100644 --- a/main.py +++ b/main.py @@ -670,16 +670,26 @@ def unrated_books(): def missing_books(): 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() for t in tmp: if t.num_books != t.count: + num_sold=0 bsl=Book_Series_Link.query.filter( Book_Series_Link.series_id==t.id ).order_by(Book_Series_Link.book_num).all() missing=[] for cnt in range(1,t.num_books+1): missing.append( cnt ) + # 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: missing.remove( b.book_num ) - # 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] } ) + tmp_book=Book.query.get(b.book_id) + if tmp_book.owned == sold[0].id: + num_sold = num_sold + 1 + if num_sold == t.count: + print( "Seems that all the books in this {} are Sold, should not list it".format(t.title)) + 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 render_template("missing.html", books=books ) @app.route("/wishlist", methods=["GET"])