diff --git a/main.py b/main.py index 0bff5e2..9b3c643 100644 --- a/main.py +++ b/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)