fix dataTables ordering when I dont expect it to for books on shelf view
This commit is contained in:
15
main.py
15
main.py
@@ -909,7 +909,7 @@ def books_on_shelf():
|
|||||||
|
|
||||||
# start with all books owned by title, but it includes sub-books, so remove them...
|
# start with all books owned by title, but it includes sub-books, so remove them...
|
||||||
# books = Book.query.join(Owned).filter(Owned.name=='Currently Owned').order_by(Book.title).all()
|
# books = Book.query.join(Owned).filter(Owned.name=='Currently Owned').order_by(Book.title).all()
|
||||||
books = Book.query.join(Owned,Book_Author_Link,Author).filter(Owned.name=='Currently Owned',Book_Author_Link.author_num==1).order_by(Author.surname,Author.firstnames,Book.title).all()
|
books = Book.query.join(Owned).join(Book_Author_Link).join(Author).filter(Owned.name=='Currently Owned').filter(Book_Author_Link.author_num==1).order_by(Author.surname,Author.firstnames,Book.title).all()
|
||||||
RemSubs(books)
|
RemSubs(books)
|
||||||
|
|
||||||
# because a book can be in multiple series, without any ordering we need to find
|
# because a book can be in multiple series, without any ordering we need to find
|
||||||
@@ -951,6 +951,8 @@ def books_on_shelf():
|
|||||||
ordered_books.append(b)
|
ordered_books.append(b)
|
||||||
|
|
||||||
# return render_template("books.html", books=ordered_books, page_title="Books on Shelf", order_by="Author(s)", show_cols='', hide_cols='' )
|
# return render_template("books.html", books=ordered_books, page_title="Books on Shelf", order_by="Author(s)", show_cols='', hide_cols='' )
|
||||||
|
for o in ordered_books:
|
||||||
|
print( f"ord: {o.title}" )
|
||||||
return render_template("books.html", books=ordered_books, page_title="Books on Shelf", order_by="", show_cols='', hide_cols='' )
|
return render_template("books.html", books=ordered_books, page_title="Books on Shelf", order_by="", show_cols='', hide_cols='' )
|
||||||
|
|
||||||
@app.route("/unrated_books", methods=["GET"])
|
@app.route("/unrated_books", methods=["GET"])
|
||||||
@@ -1026,13 +1028,16 @@ def poor_rating_books():
|
|||||||
@app.route("/fix_an")
|
@app.route("/fix_an")
|
||||||
@login_required
|
@login_required
|
||||||
def fix_an():
|
def fix_an():
|
||||||
|
print("A")
|
||||||
books=Book.query.all();
|
books=Book.query.all();
|
||||||
|
print("B")
|
||||||
for b in books:
|
for b in books:
|
||||||
|
print( f"process {b.title}")
|
||||||
cnt=1
|
cnt=1
|
||||||
for a in b.author:
|
for a in b.bals:
|
||||||
bal=Book_Author_Link.query.filter(Book_Author_Link.book_id==b.id,Book_Author_Link.author_id==a.id,Book_Author_Link.author_num == 0 ).first()
|
print( f"process bal {cnt} for {b.title}")
|
||||||
bal.author_num=cnt
|
a.author_num=cnt
|
||||||
db.session.add(bal)
|
db.session.add(a)
|
||||||
cnt+=1
|
cnt+=1
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return render_template("base.html", alert="success", message="Fixed author numbering" )
|
return render_template("base.html", alert="success", message="Fixed author numbering" )
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
{% if 'Author(s)' in order_by %}
|
{% if 'Author(s)' in order_by %}
|
||||||
{% set o = "'order': [[ 1, 'asc' ]]," %}
|
{% set o = "'order': [[ 1, 'asc' ]]," %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set o = "" %}
|
{% set o = "'order': '', " %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
document.bookdb_dt = $('#book_table').DataTable( { 'pageLength': 20, {{o|safe}} 'lengthMenu': [[10, 20, 50, -1], [10, 20, 50, "All"]] } );
|
document.bookdb_dt = $('#book_table').DataTable( { 'pageLength': 20, {{o|safe}} 'lengthMenu': [[10, 20, 50, -1], [10, 20, 50, "All"]] } );
|
||||||
} );
|
} );
|
||||||
|
|||||||
Reference in New Issue
Block a user