diff --git a/README b/README index 32f2411..6f329ea 100644 --- a/README +++ b/README @@ -30,8 +30,6 @@ sudo docker-compose -f /srv/docker/config/docker-compose.yml up bookdb_web ########################################################### TODOS (next 29): -TODO-09: show books to buy view / printable - Validation: TODO-17: view list of possible duplicate books by title TODO-18: consider which of the 'books maybe not valid' reports make sense still diff --git a/main.py b/main.py index 113c4c6..62adaba 100644 --- a/main.py +++ b/main.py @@ -679,16 +679,13 @@ def FindMissingBooks(): # 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: 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: + if num_sold != t.count: # 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 @@ -703,6 +700,12 @@ def wishlist(): books = Book.query.join(Owned).filter(Owned.name=='On Wish List').all() return render_template("books.html", books=books, page_title="Books On Wish List", show_cols='', hide_cols='Publisher,Condition,Covertype' ) +@app.route("/books_to_buy", methods=["GET"]) +def books_to_buy(): + books = Book.query.join(Owned).filter(Owned.name=='On Wish List').all() + missing = FindMissingBooks() + return render_template("to_buy.html", books=books, missing=missing, page_title="Books To Buy") + @app.route("/needs_replacing", methods=["GET"]) def needs_replacing(): books = Book.query.join(Condition,Owned).filter(Condition.name=='Needs Replacing',Owned.name=='Currently Owned').all() diff --git a/templates/to_buy.html b/templates/to_buy.html new file mode 100644 index 0000000..915674f --- /dev/null +++ b/templates/to_buy.html @@ -0,0 +1,43 @@ +{% extends "base.html" %} + +{% block main_content %} + +

{{page_title}}

+ + + + + + + {% for obj in missing %} + {% if (loop.index % 2) == 1 %} + + {% endif %} + + {% if (loop.index % 2) == 0 %} + + {% endif %} + {% endfor %} + + + + + + + + {% for book in books %} + {% if (loop.index % 2) == 1 %} + + {% endif %} + + {% if (loop.index % 2) == 0 %} + + {% endif %} + {% endfor %} + +
Book Number of SeriesSeriesBook Number of SeriesSeries
{{obj.missing}}{{obj.title}}
TitleAuthor(s)TitleAuthor(s)
{{book.title}} + {% for auth in book.author %} + {{ auth['surname'] }}, {{auth['firstnames']}} + {% endfor %} +
+{% endblock main_content %}