TODO-28 - completed and used to reduce unwanted cols for on wish list, and add rating for poor rating books

This commit is contained in:
2021-01-09 15:32:55 +11:00
parent 3c4cdeb4fb
commit 40e2ac1a34
4 changed files with 82 additions and 53 deletions

24
README
View File

@@ -30,21 +30,23 @@ sudo docker-compose -f /srv/docker/config/docker-compose.yml up bookdb_web
########################################################### TODOS (next 29): ########################################################### TODOS (next 29):
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 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
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-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 TODO-09: show books to buy view / printable
TODO-17: view list of possible duplicate books by title Validation:
TODO-18: consider which of the 'books maybe not valid' reports make sense still TODO-17: view list of possible duplicate books by title
- can you even have an N/A publisher now for example? TODO-18: consider which of the 'books maybe not valid' reports make sense still
- but the genre one is interesting - can you even have an N/A publisher now for example?
TODO-19: icons on wish list, etc.? (not sure I really want them, but if so) - but the genre one is interesting
- wishlist: search-dollar OR https://www.flaticon.com/free-icon/wishlist_868517 TODO-19: icons on wish list, etc.? (not sure I really want them, but if so)
- save: https://www.flaticon.com/free-icon/sold_463255?term=sold&page=1&position=6&related_item_id=463255 - wishlist: search-dollar OR https://www.flaticon.com/free-icon/wishlist_868517
- save: https://www.flaticon.com/free-icon/sold_463255?term=sold&page=1&position=6&related_item_id=463255
TODO-20: ORM all books load is slow Maybe:
- should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....) 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) - should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....)
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-26: gunicorn and/or more modern non-flask???

11
main.py
View File

@@ -36,7 +36,7 @@ from genre import Genre, GenreForm, GenreSchema, GetGenres
from condition import Condition, ConditionForm, ConditionSchema, GetConditionById from condition import Condition, ConditionForm, ConditionSchema, GetConditionById
from covertype import Covertype, CovertypeForm, CovertypeSchema, GetCovertypeById from covertype import Covertype, CovertypeForm, CovertypeSchema, GetCovertypeById
from owned import Owned, OwnedForm, OwnedSchema, GetOwnedById from owned import Owned, OwnedForm, OwnedSchema, GetOwnedById
from rating import Rating, RatingForm, RatingSchema from rating import Rating, RatingForm, RatingSchema, GetRatingById
from loan import Loan, LoanForm, LoanSchema from loan import Loan, LoanForm, LoanSchema
from series import Series, SeriesForm, SeriesSchema, ListOfSeriesWithMissingBooks from series import Series, SeriesForm, SeriesSchema, ListOfSeriesWithMissingBooks
@@ -237,6 +237,7 @@ app.jinja_env.globals['GetCovertypeById'] = GetCovertypeById
app.jinja_env.globals['GetOwnedById'] = GetOwnedById app.jinja_env.globals['GetOwnedById'] = GetOwnedById
app.jinja_env.globals['GetConditionById'] = GetConditionById app.jinja_env.globals['GetConditionById'] = GetConditionById
app.jinja_env.globals['GetPublisherById'] = GetPublisherById app.jinja_env.globals['GetPublisherById'] = GetPublisherById
app.jinja_env.globals['GetRatingById'] = GetRatingById
app.jinja_env.globals['SeriesBookNum'] = SeriesBookNum app.jinja_env.globals['SeriesBookNum'] = SeriesBookNum
app.jinja_env.globals['ClearStatus'] = st.ClearMessage app.jinja_env.globals['ClearStatus'] = st.ClearMessage
app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks
@@ -673,22 +674,22 @@ def missing_books():
@app.route("/wishlist", methods=["GET"]) @app.route("/wishlist", methods=["GET"])
def wishlist(): def wishlist():
books = Book.query.join(Owned).filter(Owned.name=='On Wish List').all() books = Book.query.join(Owned).filter(Owned.name=='On Wish List').all()
return render_template("books.html", books=books ) return render_template("books.html", books=books, page_title="Books On Wish List", show_cols='', hide_cols='Publisher,Condition,Covertype' )
@app.route("/needs_replacing", methods=["GET"]) @app.route("/needs_replacing", methods=["GET"])
def needs_replacing(): def needs_replacing():
books = Book.query.join(Condition,Owned).filter(Condition.name=='Needs Replacing',Owned.name=='Currently Owned').all() books = Book.query.join(Condition,Owned).filter(Condition.name=='Needs Replacing',Owned.name=='Currently Owned').all()
return render_template("books.html", books=books ) return render_template("books.html", books=books, page_title="Books that Need Replacing", show_cols='', hide_cols='' )
@app.route("/sold", methods=["GET"]) @app.route("/sold", methods=["GET"])
def sold_books(): def sold_books():
books = Book.query.join(Owned).filter(Owned.name=='Sold').all() books = Book.query.join(Owned).filter(Owned.name=='Sold').all()
return render_template("books.html", books=books ) return render_template("books.html", books=books, page_title="Books that were Sold", show_cols='', hide_cols='' )
@app.route("/poor_rating", methods=["GET"]) @app.route("/poor_rating", methods=["GET"])
def poor_rating_books(): def poor_rating_books():
books = Book.query.join(Rating,Owned).filter(Rating.id>6,Rating.name!='Undefined',Owned.name=='Currently Owned').all() 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 ) return render_template("books.html", books=books, page_title="Books that have a Poor Rating (<5 out of 10)", show_cols='Rating', hide_cols='' )
@app.route("/", methods=["GET"]) @app.route("/", methods=["GET"])

View File

@@ -103,7 +103,7 @@
</div class="collapse navbar-collapse"> </div class="collapse navbar-collapse">
</nav> </nav>
{% if message|length %} {% if message is defined and message|length %}
<div class="row alert alert-{{alert}}"> <div class="row alert alert-{{alert}}">
{{message|safe}} {{message|safe}}
{{ ClearStatus() }} {{ ClearStatus() }}

View File

@@ -1,24 +1,38 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block main_content %} {% block main_content %}
{% if page_title is not defined %}
{% set page_title="All Books" %}
{%endif %}
{% if not InDBox %} {% if not InDBox %}
<h3>All Books</h1> <h3>{{page_title}}</h1>
{% set tab_id = 'book_table' %} {% set tab_id = 'book_table' %}
{% else %} {% else %}
{% set tab_id = 'addsel_table' %} {% set tab_id = 'addsel_table' %}
{% endif %} {% endif %}
<table id="{{tab_id}}" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true"> <table id="{{tab_id}}" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
<thead> <thead>
<tr class="thead-light"><th>Title</th><th>Author(s)</th> <tr class="thead-light"><th>Title</th><th>Author(s)</th>
{% if not InDBox %} {% if not InDBox %}
<th>Publisher</th><th>Condition</th><th>Owned</th> <th>Covertype</th></tr> {% for h in ['Publisher','Condition','Owned','Covertype'] %}
{% else %} {% if h not in hide_cols %}
<th>Covertype</th><th>Add?</th></tr> <th>{{h}}</th>
{% endif %} {% endif %}
</thead> {% endfor %}
<tbody> {% for h in ['Rating'] %}
{% for book in books %} {% if h in show_cols %}
<tr> <th>{{h}}</th>
{% endif %}
{% endfor %}
{% else %}
<th>Covertype</th><th>Add?</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for book in books %}
<tr>
{% if book.sub_book_num is defined %} {% if book.sub_book_num is defined %}
<td data-sort="{{book.parent_id}}.{{book.sub_book_num}}">&nbsp;&nbsp;&nbsp;&nbsp;<a href="/book/{{book.id}}">{{book.title}}</a></td> <td data-sort="{{book.parent_id}}.{{book.sub_book_num}}">&nbsp;&nbsp;&nbsp;&nbsp;<a href="/book/{{book.id}}">{{book.title}}</a></td>
{% else %} {% else %}
@@ -29,30 +43,42 @@
{{ auth['surname'] }}, {{auth['firstnames']}} {{ auth['surname'] }}, {{auth['firstnames']}}
{% endfor %} {% endfor %}
</td> </td>
{% if not InDBox %} {% if not InDBox %}
<td>{{ GetPublisherById(book.publisher)}}</td> {% if 'Publisher' not in hide_cols %}
{% set cond = GetConditionById(book.condition) %} <td>{{ GetPublisherById(book.publisher)}}</td>
{% 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 %} {% endif %}
</td> {% if 'Condition' not in hide_cols %}
{% endif %} {% set cond = GetConditionById(book.condition) %}
<td>{{ GetOwnedById(book.owned)}}</td> {% if cond == "N/A" %}
{% endif %} <td>N/A</td>
<td>{{ GetCovertypeById(book.covertype) }}</td> {% else %}
{% if InDBox %} <td align="center">
<td><input name="addsel-{{book.id}}" type="checkbox" onClick="ActivateBFLAddSelButton()"></td> {% if cond == "Good" %}
{% endif %} <i class="fas fa-book" style="color:black"></i>
</tr> {% elif cond == "Average" %}
{% endfor %} <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 %}
{% endif %}
{% if 'Owned' not in hide_cols %}
<td>{{ GetOwnedById(book.owned)}}</td>
{% endif %}
{% endif %}
{% if 'Covertype' not in hide_cols %}
<td>{{ GetCovertypeById(book.covertype) }}</td>
{% endif %}
{% if InDBox %}
<td><input name="addsel-{{book.id}}" type="checkbox" onClick="ActivateBFLAddSelButton()"></td>
{% endif %}
{% if 'Rating' in show_cols %}
<td>{{ GetRatingById(book.rating) }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody> </tbody>
</table> </table>
{% endblock main_content %} {% endblock main_content %}