fixed bug with swapping book in series when we dont have details on book to swap with, also really disabled up/down buttons, rather than just made them look disabled
This commit is contained in:
5
BUGs
5
BUGs
@@ -1,8 +1,3 @@
|
||||
moving a book:
|
||||
with book 6 of 11, and there is no book 7: see series (Wars of Light and Shadow)
|
||||
likely logic... if no bsl2, then just increase/decrease bsl1.book_num -->
|
||||
(it would also break if we had say books 1-5 & 8 and tried to move 8 down to 7)
|
||||
|
||||
series does not deal with calcd_rating...
|
||||
(on edit could, recalc as a catch-all, and obviously if we change a single book's rating, we should re-calc)
|
||||
|
||||
|
||||
12
main.py
12
main.py
@@ -188,7 +188,10 @@ books_schema = BookSchema(many=True)
|
||||
################################# helper functions ###################################
|
||||
def GetBookIdFromSeriesByBookNum( series_id, book_num ):
|
||||
tmp_book = Book_Series_Link.query.filter(Book_Series_Link.series_id==series_id,Book_Series_Link.book_num==book_num).all()
|
||||
if len(tmp_book):
|
||||
return tmp_book[0].book_id
|
||||
else:
|
||||
return None
|
||||
|
||||
def GetBookNumBySeriesAndBookId( series_id, book_id ):
|
||||
tmp_book = Book_Series_Link.query.filter(Book_Series_Link.series_id==series_id,Book_Series_Link.book_id==book_id).all()
|
||||
@@ -244,6 +247,15 @@ def books_for_series(id):
|
||||
# swapping_with_book_num is the book_num of the book in the series we are going to swap with (notionally next/prev book in series)
|
||||
|
||||
tmp_bid = GetBookIdFromSeriesByBookNum( id, swapping_with_book_num )
|
||||
# okay, if tmp_bid is None, then there is no book we are swapping
|
||||
# with (rare case of moving say book 7 of a series of 10, and we
|
||||
# don't have details on book 6 or 8...
|
||||
if tmp_bid == None:
|
||||
if dir == "up":
|
||||
book1.MoveBookInSeries( id, -1 )
|
||||
else:
|
||||
book1.MoveBookInSeries( id, 1 )
|
||||
else:
|
||||
book2 = Book.query.get( tmp_bid )
|
||||
|
||||
# if book2 is a sub book, then we need its parent as book2 instead, as we have to move the whole book as one
|
||||
|
||||
@@ -45,18 +45,18 @@
|
||||
{% if SeriesBookNum( series.id, book.id ) == 1 %}
|
||||
<script>
|
||||
{% if book.parent_ref|length %}
|
||||
$('#up-{{book.parent_ref[0].book_id}}').addClass("disabled")
|
||||
$('#up-{{book.parent_ref[0].book_id}}').prop("disabled", true)
|
||||
{% else %}
|
||||
$('#up-{{book.id}}').addClass("disabled")
|
||||
$('#up-{{book.id}}').prop("disabled", true)
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endif %}
|
||||
{% if SeriesBookNum( series.id, book.id ) == series.num_books %}
|
||||
<script>
|
||||
{% if book.parent_ref|length %}
|
||||
$('#down-{{book.parent_ref[0].book_id}}').addClass("disabled")
|
||||
$('#down-{{book.parent_ref[0].book_id}}').prop("disabled", true)
|
||||
{% else %}
|
||||
$('#down-{{book.id}}').addClass("disabled")
|
||||
$('#down-{{book.id}}').prop("disabled", true)
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user