completed: TODO-27 dealing with series with only sold books not shown in missing list
This commit is contained in:
1
README
1
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
|
||||
|
||||
|
||||
10
main.py
10
main.py
@@ -670,14 +670,24 @@ 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 )
|
||||
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 )
|
||||
|
||||
Reference in New Issue
Block a user