fixed bug / improved how we sort parent books, we now sort it based on the first sub_books spot in the series, not the last book we retrieved from the db ordered by book.id - this does not always work if we make a parent book after other books in a series (or move books), then it was printed out of order
This commit is contained in:
15
main.py
15
main.py
@@ -171,6 +171,12 @@ def books_for_series(id):
|
||||
print( "dir="+dir)
|
||||
print( "bid="+bid)
|
||||
print( "id="+id)
|
||||
book1 = Book.query.get(bid)
|
||||
book1_s = book_schema.dump( book1 )
|
||||
# only have to check if we are a parent, as if we were a child, we
|
||||
# do not have a button to even press to cause this condition
|
||||
if len(book1_s['child_ref']):
|
||||
print( "we want to swap a parent book" )
|
||||
bsl1=Book_Series_Link.query.filter(Book_Series_Link.series_id==id, Book_Series_Link.book_id==bid).all()
|
||||
print( bsl1[0].book_num )
|
||||
if dir == "up":
|
||||
@@ -181,10 +187,17 @@ def books_for_series(id):
|
||||
print( bsl1[0].book_id )
|
||||
print( "swap with book: " )
|
||||
print( bsl2[0].book_id )
|
||||
book2 = Book.query.get(bsl2[0].book_id)
|
||||
book2_s = book_schema.dump( book2 )
|
||||
print( book2_s )
|
||||
if len(book2_s['child_ref']):
|
||||
print( "swapping with a parent book!" )
|
||||
if len(book2_s['parent_ref']):
|
||||
print( "swapping with a parent book! (and the 'next' book is a child book)" )
|
||||
bsl2[0].book_num=bsl1[0].book_num
|
||||
bsl1[0].book_num=other_bn
|
||||
db.session.commit()
|
||||
books = Book.query.join(Book_Series_Link).filter(Book_Series_Link.series_id==id).order_by(Book.id).all()
|
||||
books = Book.query.join(Book_Series_Link).filter(Book_Series_Link.series_id==id).all()
|
||||
series = Series.query.get(id)
|
||||
return render_template("books_for_series.html", books=books, series=series)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user