Fix #1992 handle invalid numbers of books seriesindex

This commit is contained in:
Ozzie Isaacs 2021-05-19 19:54:44 +02:00
parent c85cfa90a4
commit bd4fde9e63
2 changed files with 9 additions and 3 deletions

View File

@ -439,6 +439,9 @@ def edit_book_series_index(series_index, book):
# Add default series_index to book
modif_date = False
series_index = series_index or '1'
if not series_index.replace('.', '', 1).isdigit():
flash(_("%(seriesindex)s is not a valid number, skipping", seriesindex=series_index), category="warning")
return False
if book.series_index != series_index:
book.series_index = series_index
modif_date = True

View File

@ -122,9 +122,12 @@ def formatfloat(value, decimals=1):
@jinjia.app_template_filter('formatseriesindex')
def formatseriesindex_filter(series_index):
if series_index:
if int(series_index) - series_index == 0:
return int(series_index)
else:
try:
if int(series_index) - series_index == 0:
return int(series_index)
else:
return series_index
except ValueError:
return series_index
return 0