diff --git a/cps/editbooks.py b/cps/editbooks.py index 3a08f061..30535ef3 100755 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -1212,8 +1212,11 @@ def edit_list_book(param): 'newValue': ' & '.join([author.replace('|',',') for author in input_authors])}), mimetype='application/json') elif param == 'is_archived': - change_archived_books(book.id, vals['value'] == "True") - ret = "" + is_archived = change_archived_books(book.id, vals['value'] == "True", + message="Book {} archivebit set to: {}".format(book.id, vals['value'])) + if is_archived: + kobo_sync_status.remove_synced_book(book.id) + return "" elif param == 'read_status': ret = helper.edit_book_read_status(book.id, vals['value'] == "True") if ret: diff --git a/cps/helper.py b/cps/helper.py index b0b28a99..74a8dbbb 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -335,7 +335,7 @@ def edit_book_read_status(book_id, read_status=None): except (OperationalError, InvalidRequestError) as e: calibre_db.session.rollback() log.error(u"Read status could not set: {}".format(e)) - return "Read status could not set: {}".format(e), 400 + return _("Read status could not set: {}".format(e.orig)) return "" # Deletes a book fro the local filestorage, returns True if deleting is successfull, otherwise false diff --git a/cps/static/js/details.js b/cps/static/js/details.js index 6f99595d..f0259f8c 100644 --- a/cps/static/js/details.js +++ b/cps/static/js/details.js @@ -28,14 +28,24 @@ $("#have_read_cb").on("change", function() { data: $(this).closest("form").serialize(), error: function(response) { var data = [{type:"danger", message:response.responseText}] - $("#flash_success").remove(); + // $("#flash_success").parent().remove(); $("#flash_danger").remove(); + $(".row-fluid.text-center").remove(); if (!jQuery.isEmptyObject(data)) { - data.forEach(function (item) { - $(".navbar").after('
' + - '
' + item.message + '
' + - '
'); - }); + $("#have_read_cb").prop("checked", !$("#have_read_cb").prop("checked")); + if($("#bookDetailsModal").is(":visible")) { + data.forEach(function (item) { + $(".modal-header").after('
' + item.message + '
'); + }); + } else + { + data.forEach(function (item) { + $(".navbar").after('
' + + '
' + item.message + '
' + + '
'); + }); + } } } }); diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 75599d9b..b18cf229 100755 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -515,6 +515,7 @@ $(function() { $("#bookDetailsModal") .on("show.bs.modal", function(e) { + $("#flash_danger").remove(); var $modalBody = $(this).find(".modal-body"); // Prevent static assets from loading multiple times diff --git a/cps/static/js/table.js b/cps/static/js/table.js index ae8c591b..8af7592f 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -812,11 +812,13 @@ function checkboxChange(checkbox, userId, field, field_index) { function BookCheckboxChange(checkbox, userId, field) { var value = checkbox.checked ? "True" : "False"; + var element = checkbox; $.ajax({ method: "post", url: getPath() + "/ajax/editbooks/" + field, data: {"pk": userId, "value": value}, error: function(data) { + element.checked = !element.checked; handleListServerResponse([{type:"danger", message:data.responseText}]) }, success: handleListServerResponse