completed TODO-09: list of books to buy - no printable, I can just get live data on phone anyway
This commit is contained in:
2
README
2
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
|
||||
|
||||
11
main.py
11
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()
|
||||
|
||||
43
templates/to_buy.html
Normal file
43
templates/to_buy.html
Normal file
@@ -0,0 +1,43 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block main_content %}
|
||||
|
||||
<h3>{{page_title}}</h3>
|
||||
<table id="to_buy_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
||||
<thead>
|
||||
<tr class="thead-light"><th>Book Number of Series</th><th>Series</th>
|
||||
<th>Book Number of Series</th><th>Series</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for obj in missing %}
|
||||
{% if (loop.index % 2) == 1 %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td>{{obj.missing}}</td><td><a href="{{url_for('series', id=obj.id )}}">{{obj.title}}</a></td>
|
||||
{% if (loop.index % 2) == 0 %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
<thead>
|
||||
<tr class="thead-light"><th>Title</th><th>Author(s)</th>
|
||||
<th>Title</th><th>Author(s)</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for book in books %}
|
||||
{% if (loop.index % 2) == 1 %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td><a href="{{url_for('book', id=book.id )}}">{{book.title}}</a></td><td>
|
||||
{% for auth in book.author %}
|
||||
{{ auth['surname'] }}, {{auth['firstnames']}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
{% if (loop.index % 2) == 0 %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock main_content %}
|
||||
Reference in New Issue
Block a user