From 22ecdfd2bcebb306ee700096650848f04fab0333 Mon Sep 17 00:00:00 2001 From: bodybybuddha Date: Wed, 29 Aug 2018 00:49:50 -0400 Subject: [PATCH] Refactor edit_books.js for unused code; re-add glyphicon to convert button; Add form validation for convert button --- cps/static/js/edit_books.js | 3 --- cps/templates/book_edit.html | 2 +- cps/web.py | 8 ++++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cps/static/js/edit_books.js b/cps/static/js/edit_books.js index b4a98a80..1d182887 100644 --- a/cps/static/js/edit_books.js +++ b/cps/static/js/edit_books.js @@ -255,6 +255,3 @@ $("#btn-upload-cover").on("change", function () { $("#upload-cover").html(filename); }); -$("#btn-book-convert").on("change", function () { - alert("woot"); -}); diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 1efaf1f0..6a6173e9 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -48,7 +48,7 @@ - + diff --git a/cps/web.py b/cps/web.py index 9957b82a..c44e456b 100644 --- a/cps/web.py +++ b/cps/web.py @@ -3191,6 +3191,7 @@ def edit_book(book_id): except Exception: app.logger.warning(file.format.lower() + ' already removed from list.') + app.logger.debug('Allowed conversion formats:') app.logger.debug(allowed_conversion_formats) # Show form @@ -3629,6 +3630,13 @@ def upload(): @login_required_if_no_ano @edit_required def convert_bookformat(book_id): + # check to see if we have form fields to work with - if not send user back + book_format_from = request.form.get('book_format_from', None) + book_format_to = request.form.get('book_format_to', None) + + if (book_format_from is None) or (book_format_to is None): + return redirect(request.environ["HTTP_REFERER"]) + app.logger.debug('converting: book id: ' + str(book_id) + ' from: ' + request.form['book_format_from'] + ' to: ' + request.form['book_format_to'])