diff --git a/cps/admin.py b/cps/admin.py index 2c32431f..04d9138f 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -590,6 +590,8 @@ def load_dialogtexts(element_id): texts["main"] = _('Are you sure you want to change shelf sync behavior for the selected user(s)?') elif element_id == "db_submit": texts["main"] = _('Are you sure you want to change Calibre library location?') + elif element_id == "btnfullsync": + texts["main"] = _("Are you sure you want delete Calibre-Web's sync database to force a full sync with your Kobo Reader?") return json.dumps(texts) @@ -889,10 +891,18 @@ def list_restriction(res_type, user_id): else: json_dumps = "" js = json.dumps(json_dumps) - response = make_response(js) #.replace("'", '"') + response = make_response(js) response.headers["Content-Type"] = "application/json; charset=utf-8" return response +@admi.route("/ajax/fullsync") +@login_required +def ajax_fullsync(): + count = ub.session.query(ub.KoboSyncedBooks).filter(current_user.id == ub.KoboSyncedBooks.user_id).delete() + message = _("{} sync entries deleted").format(count) + ub.session_commit(message) + return Response(json.dumps([{"type": "success", "message": message}]), mimetype='application/json') + @admi.route("/ajax/pathchooser/") @login_required @@ -1189,13 +1199,13 @@ def _db_configuration_update_helper(): # if db changed -> delete shelfs, delete download books, delete read books, kobo sync... ub.session.query(ub.Downloads).delete() ub.session.query(ub.ArchivedBook).delete() - ub.session.query(ub.ArchivedBook).delete() ub.session.query(ub.ReadBook).delete() ub.session.query(ub.BookShelf).delete() ub.session.query(ub.Bookmark).delete() ub.session.query(ub.KoboReadingState).delete() ub.session.query(ub.KoboStatistics).delete() ub.session.query(ub.KoboSyncedBooks).delete() + ub.session_commit() _config_string(to_save, "config_calibre_dir") calibre_db.update_config(config) if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK): diff --git a/cps/editbooks.py b/cps/editbooks.py index 31e38d2a..21dc3ba0 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -240,14 +240,14 @@ def modify_identifiers(input_identifiers, db_identifiers, db_session): @editbook.route("/ajax/delete/") @login_required def delete_book_from_details(book_id): - return Response(delete_book(book_id, "", True), mimetype='application/json') + return Response(delete_book_from_table(book_id, "", True), mimetype='application/json') @editbook.route("/delete/", defaults={'book_format': ""}) @editbook.route("/delete//") @login_required def delete_book_ajax(book_id, book_format): - return delete_book(book_id, book_format, False) + return delete_book_from_table(book_id, book_format, False) def delete_whole_book(book_id, book): @@ -317,7 +317,7 @@ def render_delete_book_result(book_format, jsonResponse, warning, book_id): return redirect(url_for('web.index')) -def delete_book(book_id, book_format, jsonResponse): +def delete_book_from_table(book_id, book_format, jsonResponse): warning = {} if current_user.role_delete_books(): book = calibre_db.get_book(book_id) @@ -1254,7 +1254,7 @@ def merge_list_book(): element.format, element.uncompressed_size, to_name)) - delete_book(from_book.id,"", True) + delete_book_from_table(from_book.id,"", True) return json.dumps({'success': True}) return "" diff --git a/cps/kobo.py b/cps/kobo.py index 482eb13a..c5af44fc 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -209,7 +209,7 @@ def HandleSyncRequest(): books = calibre_db.session.execute(changed_entries.limit(SYNC_ITEM_LIMIT)) else: books = changed_entries.limit(SYNC_ITEM_LIMIT) - log.debug("Books to Sync: {}".format(books.count())) + log.debug("Books to Sync: {}".format(len(books.all()))) for book in books: formats = [data.format for data in book.Books.data] if not 'KEPUB' in formats and config.config_kepubifypath and 'EPUB' in formats: diff --git a/cps/services/worker.py b/cps/services/worker.py index 5952c705..076c9104 100644 --- a/cps/services/worker.py +++ b/cps/services/worker.py @@ -85,7 +85,7 @@ class WorkerThread(threading.Thread): def add(cls, user, task): ins = cls.getInstance() ins.num += 1 - log.debug("Add Task for user: {}: {}".format(user, task)) + log.debug("Add Task for user: {} - {}".format(user, task)) ins.queue.put(QueuedTask( num=ins.num, user=user, diff --git a/cps/static/js/main.js b/cps/static/js/main.js index cf6fbe0d..585d2296 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -517,6 +517,7 @@ $(function() { .on("hidden.bs.modal", function() { $(this).find(".modal-body").html("..."); $("#config_delete_kobo_token").show(); + $("#kobo_full_sync").show(); }); $("#config_delete_kobo_token").click(function() { @@ -530,6 +531,7 @@ $(function() { url: getPath() + "/kobo_auth/deleteauthtoken/" + value, }); $("#config_delete_kobo_token").hide(); + $("#kobo_full_sync").hide(); } ); }); @@ -563,6 +565,33 @@ $(function() { } ); }); + + $("#kobo_full_sync").click(function() { + confirmDialog( + "btnfullsync", + "GeneralDeleteModal", + $(this).data('value'), + function(value){ + path = getPath() + "/ajax/fullsync" + $.ajax({ + method:"get", + url: path, + timeout: 900, + success:function(data) { + data.forEach(function(item) { + if (!jQuery.isEmptyObject(item)) { + $( ".navbar" ).after( '
' + + '
'+item.message+'
' + + '
'); + } + }); + } + }); + } + ); + }); + + $("#user_submit").click(function() { this.closest("form").submit(); }); diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index edecbaf2..e6fbdb74 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -66,6 +66,9 @@ {{_('Create/View')}} +
+ +
{% endif %}
{% for element in sidebar %} diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index dea6d5e9..3c54e88b 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2021-12-02 06:37:36

+

Start Time: 2021-12-05 19:18:28

-

Stop Time: 2021-12-02 10:15:15

+

Stop Time: 2021-12-05 22:58:48

-

Duration: 2h 57 min

+

Duration: 3h 0 min

@@ -1858,12 +1858,12 @@ - + TestKoboSync 11 - 6 - 4 - 1 + 2 + 9 + 0 0 Detail @@ -1872,11 +1872,35 @@ - +
TestKoboSync - test_book_download
- PASS + +
+ FAIL +
+ + + + @@ -1890,26 +1914,30 @@ - +
TestKoboSync - test_kobo_sync_selected_shelfs
- ERROR + FAIL
-
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 481, in test_shelves_add_remove_books
-    self.assertEqual(1, len(books))
-AssertionError: 1 != 0
+ File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 447, in test_shelves_add_remove_books + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 111, in inital_sync + self.assertEqual(r.json(), {}) +AssertionError: {'Benefits': {}} != {} +- {'Benefits': {}} ++ {}
@@ -1974,9 +2030,13 @@ AssertionError: 1 != 0
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 286, in test_sync_changed_book
-    self.assertEqual(1, len(data))
-AssertionError: 1 != 2
+ File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 277, in test_sync_changed_book + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 111, in inital_sync + self.assertEqual(r.json(), {}) +AssertionError: {'Benefits': {}} != {} +- {'Benefits': {}} ++ {}
@@ -1995,11 +2055,35 @@ AssertionError: 1 != 2 - +
TestKoboSync - test_sync_reading_state
- PASS + +
+ FAIL +
+ + + + @@ -2021,9 +2105,13 @@ AssertionError: 1 != 2
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 304, in test_sync_shelf
-    self.assertEqual(1, len(data))
-AssertionError: 1 != 0
+ File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 296, in test_sync_shelf + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 111, in inital_sync + self.assertEqual(r.json(), {}) +AssertionError: {'Benefits': {}} != {} +- {'Benefits': {}} ++ {}
@@ -2033,11 +2121,35 @@ AssertionError: 1 != 0 - +
TestKoboSync - test_sync_unchanged
- PASS + +
+ FAIL +
+ + + + @@ -2059,9 +2171,13 @@ AssertionError: 1 != 0
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 270, in test_sync_upload
-    self.assertEqual(1, len(data))
-AssertionError: 1 != 0
+ File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 256, in test_sync_upload + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 111, in inital_sync + self.assertEqual(r.json(), {}) +AssertionError: {'Benefits': {}} != {} +- {'Benefits': {}} ++ {}
@@ -2072,11 +2188,11 @@ AssertionError: 1 != 0 - + TestKoboSyncBig 5 - 5 - 0 + 1 + 4 0 0 @@ -2095,38 +2211,134 @@ AssertionError: 1 != 0 - +
TestKoboSyncBig - test_kobo_sync_selected_shelfs
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_sync_changed_book
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_sync_reading_state
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_sync_shelf
- PASS + +
+ FAIL +
+ + + + @@ -3844,51 +4056,322 @@ AssertionError: 0 != 1 - - _FailedTest - 1 + + TestCalibreWebVisibilitys + 34 + 34 0 0 - 1 0 - Detail + Detail - + -
_FailedTest - test_visiblilitys
+
TestCalibreWebVisibilitys - test_about
- -
- ERROR -
- - - + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_SMTP_Settings
+ PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_add_user
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_password
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_archived
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_authors
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_category
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_file_formats
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_hot
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_language
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_publisher
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_random
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_rated
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_rating
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_read
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_admin_change_visibility_series
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_allow_columns
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_allow_tags
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_archive_books
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_authors_max_settings
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_change_title
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_checked_logged_in
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_hide_custom_column
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_link_column_to_read_status
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_random_books_available
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_request_link_column_to_read_status
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_restrict_columns
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_restrict_tags
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_save_views_recent
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_search_functions
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_search_order
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_search_string
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_user_email_available
+ + PASS + + + + + + +
TestCalibreWebVisibilitys - test_user_visibility_sidebar
+ + PASS @@ -4054,10 +4537,10 @@ SyntaxError: invalid syntax Total - 345 - 332 - 5 - 2 + 378 + 358 + 14 + 0 6   @@ -4086,7 +4569,7 @@ SyntaxError: invalid syntax Platform - Linux 5.13.0-21-generic #21~20.04.1-Ubuntu SMP Tue Oct 26 15:49:20 UTC 2021 x86_64 x86_64 + Linux 5.13.0-22-generic #22~20.04.1-Ubuntu SMP Tue Nov 9 15:07:24 UTC 2021 x86_64 x86_64 Basic @@ -4242,7 +4725,7 @@ SyntaxError: invalid syntax google-api-python-client - 2.31.0 + 2.32.0 TestCliGdrivedb @@ -4272,7 +4755,7 @@ SyntaxError: invalid syntax google-api-python-client - 2.31.0 + 2.32.0 TestEbookConvertCalibreGDrive @@ -4302,7 +4785,7 @@ SyntaxError: invalid syntax google-api-python-client - 2.31.0 + 2.32.0 TestEbookConvertGDriveKepubify @@ -4344,7 +4827,7 @@ SyntaxError: invalid syntax google-api-python-client - 2.31.0 + 2.32.0 TestEditBooksOnGdrive @@ -4374,7 +4857,7 @@ SyntaxError: invalid syntax google-api-python-client - 2.31.0 + 2.32.0 TestSetupGdrive @@ -4464,7 +4947,7 @@ SyntaxError: invalid syntax