From 4f386c8a00a68973f01894ba744e1a26e5776403 Mon Sep 17 00:00:00 2001 From: bodybybuddha Date: Tue, 28 Aug 2018 19:13:04 -0400 Subject: [PATCH] Updated GUI buttons for ebook-convert feature --- cps/helper.py | 5 ++++ cps/static/js/edit_books.js | 4 ++++ cps/templates/book_edit.html | 45 +++++++++++++++++++++++++----------- cps/web.py | 21 +++++++++++------ 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 5285b13e..152bcd25 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -135,6 +135,11 @@ def send_mail(book_id, kindle_mail, calibrepath, user_id): return _(u"The requested file could not be read. Maybe wrong permissions?") +# Convert existing book entry to new format +#def convert_book_format(book_id, calibrepath, new_book_format, user_id): + +# return + def get_valid_filename(value, replace_whitespace=True): """ Returns the given string converted to a string that can be used for a clean diff --git a/cps/static/js/edit_books.js b/cps/static/js/edit_books.js index e86c78e9..b4a98a80 100644 --- a/cps/static/js/edit_books.js +++ b/cps/static/js/edit_books.js @@ -254,3 +254,7 @@ $("#btn-upload-cover").on("change", function () { } // Remove c:\fake at beginning from localhost chrome $("#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 abe41923..1efaf1f0 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% block body %} {% if book %} -
+
@@ -25,7 +25,37 @@
{% endif %} {% endif %} + +{% if display_convertbtn and conversion_formats|length > 0 %} +

{{_('Convert book format:')}}

+ +
+
+ + + + +
+
+ + + + +
+{% endif %} +
+
@@ -136,19 +166,6 @@
- - {% if display_convertbtn and conversion_formats|length > 0 %} - - - {% endif %} -
{% endif %} diff --git a/cps/web.py b/cps/web.py index ce05c354..9908de2f 100644 --- a/cps/web.py +++ b/cps/web.py @@ -3183,16 +3183,10 @@ def edit_book(book_id): else: display_convertbtn = False - app.logger.debug(book) - app.logger.debug(book.data) #Determine what formats don't already exist allowed_conversion_formats = ALLOWED_EXTENSIONS for file in book.data: - try: - allowed_conversion_formats.remove(file.format.lower()) - except Exception: - app.logger.debug("Exception thrown:") - app.logger.debug(file.format.lower()) + allowed_conversion_formats.remove(file.format.lower()) app.logger.debug(allowed_conversion_formats) @@ -3627,3 +3621,16 @@ def upload(): title=book.title, books_shelfs=book_in_shelfs, page="upload") return redirect(url_for("index")) + +@app.route("/admin/book/convert/", methods=['POST']) +@login_required_if_no_ano +@edit_required +def convert_bookformat(book_id): + # rtn = convert_book_format(book_id, calibrepath, new_book_format, user_id) + app.logger.debug('got here') + app.logger.debug('book id:' + str(book_id)) + app.logger.debug('from format:'+request.form['book_format_from']) + app.logger.debug('to format:' + request.form['book_format_to']) + + return redirect(url_for("index")) +