completed TODOs 13, 14, 15, 16 - views of subsets of books. Added 2 new TODOs to enhance their output / make the views better

This commit is contained in:
2021-01-09 01:13:26 +11:00
parent a6211928df
commit cd7a77ff6b
5 changed files with 59 additions and 16 deletions

8
README
View File

@@ -29,12 +29,8 @@ sudo docker-compose -f /srv/docker/config/docker-compose.yml up bookdb_web
MUST use form.errors when we have a validator that is fancier than not empty (year_published in book and num_books in series SO FAR)
########################################################### TODOS (next 27):
########################################################### TODOS (next 29):
TODO-09: show books to buy view / printable
TODO-13: show books on wish list
TODO-14: show books that need replacing
TODO-15: show books I have sold
TODO-16: show books with poor rating
TODO-17: view list of possible duplicate books by title
TODO-18: consider which of the 'books maybe not valid' reports make sense still
- can you even have an N/A publisher now for example?
@@ -49,3 +45,5 @@ TODO-20: ORM all books load is slow
TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book)
TODO-26: gunicorn and/or more modern non-flask???
TODO-27: from missing, exclude any series where the only books we have are SOLD
TODO-28: make books.html have page_title? and pass in a 'print these cols'... at least for poor ratings, etc. so we can hide dud columns, and show more useful ones

23
main.py
View File

@@ -666,10 +666,31 @@ def missing_books():
missing.append( cnt )
for b in bsl:
missing.remove( b.book_num )
# turn missing from array into string, and strip 0 and last char (the square brackets)
# 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"])
def wishlist():
books = Book.query.join(Owned).filter(Owned.name=='On Wish List').all()
return render_template("books.html", books=books )
@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()
return render_template("books.html", books=books )
@app.route("/sold", methods=["GET"])
def sold_books():
books = Book.query.join(Owned).filter(Owned.name=='Sold').all()
return render_template("books.html", books=books )
@app.route("/poor_rating", methods=["GET"])
def poor_rating_books():
books = Book.query.join(Rating,Owned).filter(Rating.id>6,Rating.name!='Undefined',Owned.name=='Currently Owned').all()
return render_template("books.html", books=books )
@app.route("/", methods=["GET"])
def main_page():
return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage())

View File

@@ -49,7 +49,11 @@
<a class="dropdown-item" href="{{url_for('books')}}">Show All</a>
<a class="dropdown-item" href="{{url_for('books_on_shelf')}}">Show Books on shelf</a>
<a class="dropdown-item" href="{{url_for('unrated_books')}}">Show Unrated_Books</a>
<a class="dropdown-item" href="{{url_for('wishlist')}}">Show Books on wishlist</a>
<a class="dropdown-item" href="{{url_for('missing_books')}}">Show Missing Books</a>
<a class="dropdown-item" href="{{url_for('poor_rating_books')}}">Show Books that scored &lt; 5/10</a>
<a class="dropdown-item" href="{{url_for('needs_replacing')}}">Show Books that Need Replacing</a>
<a class="dropdown-item" href="{{url_for('sold_books')}}">Show Books that have been Sold </a>
<a class="dropdown-item" href="{{url_for('stats')}}">Show Stats</a>
</div>
</div class="nav-item dropdown">

View File

@@ -31,16 +31,20 @@
</td>
{% if not InDBox %}
<td>{{ GetPublisherById(book.publisher)}}</td>
<td align="center">
{% set cond = GetConditionById(book.condition) %}
{% if cond == "Good" %}
<i class="fas fa-book" style="color:black"></i>
{% elif cond == "Average" %}
<i class="fas fa-book" style="color:orange"></i>
{% else %}
<i class="fas fa-book" style="color:red"></i>
{% endif %}
</td>
{% set cond = GetConditionById(book.condition) %}
{% if cond == "N/A" %}
<td>N/A</td>
{% else %}
<td align="center">
{% if cond == "Good" %}
<i class="fas fa-book" style="color:black"></i>
{% elif cond == "Average" %}
<i class="fas fa-book" style="color:orange"></i>
{% elif cond == "Needs Replacing" %}
<i class="fas fa-book" style="color:red"></i>
{% endif %}
</td>
{% endif %}
<td>{{ GetOwnedById(book.owned)}}</td>
{% endif %}
<td>{{ GetCovertypeById(book.covertype) }}</td>

16
templates/missing.html Normal file
View File

@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block main_content %}
<h3>Missing Books</h3>
<table id="missing_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
<thead>
<tr class="thead-light"><th>Books</th><th>Series</th><th>Number of Books in Series</th></tr>
</thead>
<tbody>
{% for obj in books %}
<tr><td>{{obj.missing}}</td><td><a href="{{url_for('series', id=obj.id )}}">{{obj.title}}</a></td><td>{{obj.num_books}}</td></tr>
{% endfor %}
</tbody>
</table>
{% endblock main_content %}