fixed books on shelf BUG-16 - author missing, its now using ORM with a HACK to remove subs not via ORM, and I also fixed datatable sorting by author for books on shelf via a param past into base.html
This commit is contained in:
2
BUGs
2
BUGs
@@ -1,4 +1,4 @@
|
|||||||
#### BUGS (next-16)
|
#### BUGS (next-17)
|
||||||
|
|
||||||
### DB/back-end
|
### DB/back-end
|
||||||
BUG-2: series does not deal with calcd_rating...
|
BUG-2: series does not deal with calcd_rating...
|
||||||
|
|||||||
1
README
1
README
@@ -30,7 +30,6 @@ sudo docker-compose -f /srv/docker/config/docker-compose.yml up bookdb_web
|
|||||||
|
|
||||||
|
|
||||||
########################################################### TODOS (next 29):
|
########################################################### TODOS (next 29):
|
||||||
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-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
|
||||||
|
|||||||
19
main.py
19
main.py
@@ -231,6 +231,15 @@ def AddSubs(books):
|
|||||||
books[index].parent_id = row.book_id
|
books[index].parent_id = row.book_id
|
||||||
books[index].sub_book_num = row.sub_book_num
|
books[index].sub_book_num = row.sub_book_num
|
||||||
|
|
||||||
|
# HACK: Couldn't work out ORM to excluded sub_book self-ref, so using basic python
|
||||||
|
# loop to remove sub_books from list
|
||||||
|
def RemSubs(books):
|
||||||
|
subs = db.engine.execute ( "select * from book_sub_book_link" )
|
||||||
|
for row in subs:
|
||||||
|
for i, item in enumerate(books):
|
||||||
|
if item.id == row.sub_book_id:
|
||||||
|
books.remove(item)
|
||||||
|
|
||||||
####################################### GLOBALS #######################################
|
####################################### GLOBALS #######################################
|
||||||
# allow jinja2 to call these python functions directly
|
# allow jinja2 to call these python functions directly
|
||||||
app.jinja_env.globals['GetCovertypeById'] = GetCovertypeById
|
app.jinja_env.globals['GetCovertypeById'] = GetCovertypeById
|
||||||
@@ -243,6 +252,7 @@ app.jinja_env.globals['ClearStatus'] = st.ClearMessage
|
|||||||
app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks
|
app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks
|
||||||
|
|
||||||
book_schema = BookSchema()
|
book_schema = BookSchema()
|
||||||
|
books_schema = BookSchema(many=True)
|
||||||
|
|
||||||
####################################### ROUTES #######################################
|
####################################### ROUTES #######################################
|
||||||
@app.route("/search", methods=["POST"])
|
@app.route("/search", methods=["POST"])
|
||||||
@@ -647,13 +657,14 @@ def rem_parent_books_from_series(pid):
|
|||||||
|
|
||||||
@app.route("/books_on_shelf", methods=["GET"])
|
@app.route("/books_on_shelf", methods=["GET"])
|
||||||
def books_on_shelf():
|
def books_on_shelf():
|
||||||
books = db.engine.execute("select * from book where id not in ( select sub_book_id from book_sub_book_link ) and owned = (select id from owned where name = 'Currently Owned')")
|
books = Book.query.join(Owned).filter(Owned.name=='Currently Owned').all()
|
||||||
return render_template("books.html", books=books )
|
RemSubs(books)
|
||||||
|
return render_template("books.html", books=books, page_title="Books on Shelf", order_by="Author(s)", show_cols='', hide_cols='' )
|
||||||
|
|
||||||
@app.route("/unrated_books", methods=["GET"])
|
@app.route("/unrated_books", methods=["GET"])
|
||||||
def unrated_books():
|
def unrated_books():
|
||||||
books = db.engine.execute("select * from book where rating = (select id from rating where name = 'Undefined') and owned = (select id from owned where name = 'Currently Owned')")
|
books = Book.query.join(Condition,Owned).filter(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 with no rating", show_cols='Rating', hide_cols='' )
|
||||||
|
|
||||||
@app.route("/missing_books", methods=["GET"])
|
@app.route("/missing_books", methods=["GET"])
|
||||||
def missing_books():
|
def missing_books():
|
||||||
|
|||||||
@@ -122,7 +122,12 @@
|
|||||||
<script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
|
<script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#book_table').DataTable( { 'pageLength': 20, 'lengthMenu': [[10, 20, 50, -1], [10, 20, 50, "All"]] } );
|
{% if 'Author(s)' in order_by %}
|
||||||
|
{% set o = "'order': [[ 1, 'asc' ]]," %}
|
||||||
|
{% else %}
|
||||||
|
{% set o = "" %}
|
||||||
|
{% endif %}
|
||||||
|
document.bookdb_dt = $('#book_table').DataTable( { 'pageLength': 20, {{o|safe}} 'lengthMenu': [[10, 20, 50, -1], [10, 20, 50, "All"]] } );
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
{%block script_content %}{% endblock script_content %}
|
{%block script_content %}{% endblock script_content %}
|
||||||
|
|||||||
Reference in New Issue
Block a user