Bugfix edit series_index
Bugfix invalid languages
This commit is contained in:
parent
7f9da94a18
commit
87e526642c
|
@ -31,7 +31,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Improve this to check if scholarly is available in a global way, like other pythonic libraries
|
# Improve this to check if scholarly is available in a global way, like other pythonic libraries
|
||||||
try:
|
try:
|
||||||
from scholarly import scholarly
|
from scholarly import scholarly
|
||||||
|
@ -454,7 +453,7 @@ def edit_book_series_index(series_index, book):
|
||||||
if not series_index.replace('.', '', 1).isdigit():
|
if not series_index.replace('.', '', 1).isdigit():
|
||||||
flash(_("%(seriesindex)s is not a valid number, skipping", seriesindex=series_index), category="warning")
|
flash(_("%(seriesindex)s is not a valid number, skipping", seriesindex=series_index), category="warning")
|
||||||
return False
|
return False
|
||||||
if book.series_index != series_index:
|
if str(book.series_index) != series_index:
|
||||||
book.series_index = series_index
|
book.series_index = series_index
|
||||||
modif_date = True
|
modif_date = True
|
||||||
return modif_date
|
return modif_date
|
||||||
|
@ -484,11 +483,11 @@ def edit_book_languages(languages, book, upload=False, invalid=None):
|
||||||
else:
|
else:
|
||||||
input_l = isoLanguages.get_valid_language_codes(get_locale(), input_languages, unknown_languages)
|
input_l = isoLanguages.get_valid_language_codes(get_locale(), input_languages, unknown_languages)
|
||||||
for l in unknown_languages:
|
for l in unknown_languages:
|
||||||
log.error('%s is not a valid language', l)
|
log.error("'%s' is not a valid language", l)
|
||||||
if isinstance(invalid, list):
|
if isinstance(invalid, list):
|
||||||
invalid.append(l)
|
invalid.append(l)
|
||||||
else:
|
else:
|
||||||
flash(_(u"%(langname)s is not a valid language", langname=l), category="warning")
|
raise ValueError(_(u"'%(langname)s' is not a valid language", langname=l))
|
||||||
# ToDo: Not working correct
|
# ToDo: Not working correct
|
||||||
if upload and len(input_l) == 1:
|
if upload and len(input_l) == 1:
|
||||||
# If the language of the file is excluded from the users view, it's not imported, to allow the user to view
|
# If the language of the file is excluded from the users view, it's not imported, to allow the user to view
|
||||||
|
@ -848,6 +847,10 @@ def edit_book(book_id):
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
flash(error, category="error")
|
flash(error, category="error")
|
||||||
return render_edit_book(book_id)
|
return render_edit_book(book_id)
|
||||||
|
except ValueError as e:
|
||||||
|
calibre_db.session.rollback()
|
||||||
|
flash(str(e), category="error")
|
||||||
|
return redirect(url_for('web.show_book', book_id=book.id))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.debug_or_exception(ex)
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
|
@ -944,7 +947,11 @@ def create_book_on_upload(modif_date, meta):
|
||||||
modif_date |= edit_book_series_index(meta.series_id, db_book)
|
modif_date |= edit_book_series_index(meta.series_id, db_book)
|
||||||
|
|
||||||
# add languages
|
# add languages
|
||||||
modif_date |= edit_book_languages(meta.languages, db_book, upload=True)
|
invalid=[]
|
||||||
|
modif_date |= edit_book_languages(meta.languages, db_book, upload=True, invalid=invalid)
|
||||||
|
if invalid:
|
||||||
|
for l in invalid:
|
||||||
|
flash(_(u"'%(langname)s' is not a valid language", langname=l), category="warning")
|
||||||
|
|
||||||
# handle tags
|
# handle tags
|
||||||
modif_date |= edit_book_tags(meta.tags, db_book)
|
modif_date |= edit_book_tags(meta.tags, db_book)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user