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:
24
README
24
README
@@ -30,21 +30,23 @@ 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-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-09: show books to buy view / printable
|
||||
|
||||
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?
|
||||
- but the genre one is interesting
|
||||
TODO-19: icons on wish list, etc.? (not sure I really want them, but if so)
|
||||
- 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
|
||||
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
|
||||
- can you even have an N/A publisher now for example?
|
||||
- but the genre one is interesting
|
||||
TODO-19: icons on wish list, etc.? (not sure I really want them, but if so)
|
||||
- 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
|
||||
- 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)
|
||||
Maybe:
|
||||
TODO-20: ORM all books load is slow
|
||||
- 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???
|
||||
|
||||
11
main.py
11
main.py
@@ -36,7 +36,7 @@ from genre import Genre, GenreForm, GenreSchema, GetGenres
|
||||
from condition import Condition, ConditionForm, ConditionSchema, GetConditionById
|
||||
from covertype import Covertype, CovertypeForm, CovertypeSchema, GetCovertypeById
|
||||
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 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['GetConditionById'] = GetConditionById
|
||||
app.jinja_env.globals['GetPublisherById'] = GetPublisherById
|
||||
app.jinja_env.globals['GetRatingById'] = GetRatingById
|
||||
app.jinja_env.globals['SeriesBookNum'] = SeriesBookNum
|
||||
app.jinja_env.globals['ClearStatus'] = st.ClearMessage
|
||||
app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks
|
||||
@@ -673,22 +674,22 @@ def missing_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 )
|
||||
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"])
|
||||
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 )
|
||||
return render_template("books.html", books=books, page_title="Books that Need Replacing", show_cols='', hide_cols='' )
|
||||
|
||||
@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 )
|
||||
return render_template("books.html", books=books, page_title="Books that were Sold", show_cols='', hide_cols='' )
|
||||
|
||||
@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 )
|
||||
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"])
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
</div class="collapse navbar-collapse">
|
||||
</nav>
|
||||
|
||||
{% if message|length %}
|
||||
{% if message is defined and message|length %}
|
||||
<div class="row alert alert-{{alert}}">
|
||||
{{message|safe}}
|
||||
{{ ClearStatus() }}
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
{% extends "base.html" %}
|
||||
{% block main_content %}
|
||||
|
||||
{% if page_title is not defined %}
|
||||
{% set page_title="All Books" %}
|
||||
{%endif %}
|
||||
|
||||
{% if not InDBox %}
|
||||
<h3>All Books</h1>
|
||||
<h3>{{page_title}}</h1>
|
||||
{% set tab_id = 'book_table' %}
|
||||
{% else %}
|
||||
{% set tab_id = 'addsel_table' %}
|
||||
{% endif %}
|
||||
<table id="{{tab_id}}" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
||||
<thead>
|
||||
<tr class="thead-light"><th>Title</th><th>Author(s)</th>
|
||||
{% if not InDBox %}
|
||||
<th>Publisher</th><th>Condition</th><th>Owned</th> <th>Covertype</th></tr>
|
||||
{% else %}
|
||||
<th>Covertype</th><th>Add?</th></tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for book in books %}
|
||||
<tr>
|
||||
<thead>
|
||||
<tr class="thead-light"><th>Title</th><th>Author(s)</th>
|
||||
{% if not InDBox %}
|
||||
{% for h in ['Publisher','Condition','Owned','Covertype'] %}
|
||||
{% if h not in hide_cols %}
|
||||
<th>{{h}}</th>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for h in ['Rating'] %}
|
||||
{% if h in show_cols %}
|
||||
<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 %}
|
||||
<td data-sort="{{book.parent_id}}.{{book.sub_book_num}}"> <a href="/book/{{book.id}}">{{book.title}}</a></td>
|
||||
{% else %}
|
||||
@@ -29,30 +43,42 @@
|
||||
{{ auth['surname'] }}, {{auth['firstnames']}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
{% if not InDBox %}
|
||||
<td>{{ GetPublisherById(book.publisher)}}</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>
|
||||
{% if not InDBox %}
|
||||
{% if 'Publisher' not in hide_cols %}
|
||||
<td>{{ GetPublisherById(book.publisher)}}</td>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
<td>{{ GetOwnedById(book.owned)}}</td>
|
||||
{% endif %}
|
||||
<td>{{ GetCovertypeById(book.covertype) }}</td>
|
||||
{% if InDBox %}
|
||||
<td><input name="addsel-{{book.id}}" type="checkbox" onClick="ActivateBFLAddSelButton()"></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if 'Condition' not in hide_cols %}
|
||||
{% 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 %}
|
||||
{% 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>
|
||||
</table>
|
||||
</table>
|
||||
{% endblock main_content %}
|
||||
|
||||
Reference in New Issue
Block a user