From ef74fccab3a18e41aa6bcbb4bb04b59d2d540a33 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 28 Nov 2020 18:27:17 +1100 Subject: [PATCH] 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 --- templates/books_for_series.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/books_for_series.html b/templates/books_for_series.html index 286e90d..451b0fe 100644 --- a/templates/books_for_series.html +++ b/templates/books_for_series.html @@ -3,7 +3,6 @@ TitleBook Number - {% set last = namespace(val=0) %} {% for book in books %} @@ -30,10 +29,14 @@ {% set num = SeriesBookNum( series.id, book.id ) %} {% if num == None %} - {# okay, if this is a parent book, the num == None, so make it use last real-book and add .01 to it to make sure it sorts just after the last one #} - + {# okay, if this is a parent book, the num == None, so find first child / sub_book's book number in the series #} + {# then we treat each book_num as a 0-leading 3 digit number - for the parent book we minus 1 from it #} + {% set tmp = SeriesBookNum( series.id, book.child_ref[0].sub_book_id ) %} + {% set num = "{:02d}0".format( tmp ) %} + {% set num = num|int - 1 %} + {% else %} - + {% endif %} {% for s in book.series %} {% if not book.child_ref|length %} @@ -57,7 +60,6 @@ {% endif %} {% endif %} - {% set last.val = num %} {% endfor %}