From aa4a5dc3ef3bb2b92229432d7ef21c4ce09e9a7d Mon Sep 17 00:00:00 2001 From: kyos Date: Wed, 9 Aug 2017 19:56:46 +0200 Subject: [PATCH 1/7] Added option to upload a new format to a given book --- cps/static/css/style.css | 3 +++ cps/static/js/edit_books.js | 8 ++++++ cps/templates/book_edit.html | 12 +++++++-- cps/translations/es/LC_MESSAGES/messages.po | 4 +++ cps/web.py | 29 +++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 87f7b4c5..f934b62a 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -62,3 +62,6 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te #shelf-action-errors { margin-left: 5px; } + +.upload-format-input-text {display: initial;} +#btn-upload-format {display: none;} diff --git a/cps/static/js/edit_books.js b/cps/static/js/edit_books.js index 5438e7b0..0b4ecd45 100644 --- a/cps/static/js/edit_books.js +++ b/cps/static/js/edit_books.js @@ -200,3 +200,11 @@ $("#search").on("change input.typeahead:selected", function(){ }); }); }); + +$("#btn-upload-format").on('change', function () { + var filename = $(this).val(); + if (filename.substring(3,11) == 'fakepath') { + filename = filename.substring(12); + } // Remove c:\fake at beginning from localhost chrome + $('#upload-format').html(filename); +}); diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 9bd1e644..a292e68d 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% block body %} {% if book %} -
+
@@ -115,7 +115,15 @@
{% endfor %} {% endif %} - + {% if g.user.role_upload() or g.user.role_admin()%} + {% if g.allow_upload %} +
+ +
+ +
+ {% endif %} + {% endif %}