From c7f02935680f0cac81cd04694f064cd3652821da Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Wed, 14 Aug 2024 18:21:15 +0200 Subject: [PATCH 1/2] Implementation of sorting according to shelf added --- cps/shelf.py | 7 +++++-- cps/static/js/main.js | 2 ++ cps/templates/locales/en/translation.json | 10 ---------- cps/templates/shelf.html | 2 ++ cps/ub.py | 1 - 5 files changed, 9 insertions(+), 13 deletions(-) delete mode 100644 cps/templates/locales/en/translation.json diff --git a/cps/shelf.py b/cps/shelf.py index 6558e8d594..41d5ce1d9c 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -422,11 +422,14 @@ def render_show_shelf(shelf_type, shelf_id, page_no, sort_param): # check user is allowed to access shelf if shelf and check_shelf_view_permissions(shelf): if shelf_type == 1: - # order = [ub.BookShelf.order.asc()] if sort_param == 'pubnew': change_shelf_order(shelf_id, [db.Books.pubdate.desc()]) if sort_param == 'pubold': change_shelf_order(shelf_id, [db.Books.pubdate]) + if sort_param == 'shelfnew': + change_shelf_order(shelf_id, [ub.BookShelf.date_added.desc()]) + if sort_param == 'shelfold': + change_shelf_order(shelf_id, [ub.BookShelf.date_added]) if sort_param == 'abc': change_shelf_order(shelf_id, [db.Books.sort]) if sort_param == 'zyx': @@ -453,7 +456,7 @@ def render_show_shelf(shelf_type, shelf_id, page_no, sort_param): [ub.BookShelf.order.asc()], True, config.config_read_column, ub.BookShelf, ub.BookShelf.book_id == db.Books.id) - # delete chelf entries where book is not existent anymore, can happen if book is deleted outside calibre-web + # delete shelf entries where book is not existent anymore, can happen if book is deleted outside calibre-web wrong_entries = calibre_db.session.query(ub.BookShelf) \ .join(db.Books, ub.BookShelf.book_id == db.Books.id, isouter=True) \ .filter(db.Books.id == None).all() diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 72f01867b1..2dbea6bc24 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -612,6 +612,8 @@ $(function() { $("#auth_za").toggleClass("disabled"); $("#pub_new").toggleClass("disabled"); $("#pub_old").toggleClass("disabled"); + $("#shelf_new").toggleClass("disabled"); + $("#shelf_old").toggleClass("disabled"); var alternative_text = $("#toggle_order_shelf").data('alt-text'); $("#toggle_order_shelf").data('alt-text', $("#toggle_order_shelf").html()); $("#toggle_order_shelf").html(alternative_text); diff --git a/cps/templates/locales/en/translation.json b/cps/templates/locales/en/translation.json deleted file mode 100644 index 655669eeb2..0000000000 --- a/cps/templates/locales/en/translation.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "input": { - "placeholder": "a placeholder" - }, - "nav": { - "home": "Home", - "page1": "Page One", - "page2": "Page Two" - } -} \ No newline at end of file diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index bf0b1ab43d..d0fdb3999e 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -25,6 +25,8 @@

{{title}}

+ + {% endif %} {% endif %} diff --git a/cps/ub.py b/cps/ub.py index e548cc12f6..8bc388458b 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -311,7 +311,6 @@ def loadSettings(self): self.view_settings = data.view_settings self.kobo_only_shelves_sync = data.kobo_only_shelves_sync - def role_admin(self): return False From d2860fc3749524d4942f0808a856ef543b5caa5f Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Thu, 15 Aug 2024 18:35:48 +0200 Subject: [PATCH 2/2] Final fix for cover size during kobo sync (fix for #2523) Update Teststatus --- cps/kobo.py | 9 +- test/Calibre-Web TestSummary_Linux.html | 694 ++++++++++++++++-------- 2 files changed, 475 insertions(+), 228 deletions(-) diff --git a/cps/kobo.py b/cps/kobo.py index 03fc29c3ca..8903056e8c 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -47,7 +47,7 @@ from . import config, logger, kobo_auth, db, calibre_db, helper, shelf as shelf_lib, ub, csrf, kobo_sync_status from . import isoLanguages from .epub import get_epub_layout -from .constants import COVER_THUMBNAIL_SMALL +from .constants import COVER_THUMBNAIL_SMALL, COVER_THUMBNAIL_MEDIUM from .helper import get_download_link from .services import SyncToken as SyncToken from .web import download_required @@ -903,7 +903,12 @@ def get_current_bookmark_response(current_bookmark): @requires_kobo_auth def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale): try: - resolution = None if int(height) > 1000 else COVER_THUMBNAIL_SMALL + if int(height) > 1000: + resolution = None + elif int(height) > 500: + resolution = COVER_THUMBNAIL_MEDIUM + else: + resolution = COVER_THUMBNAIL_SMALL except ValueError: log.error("Requested height %s of book %s is invalid" % (book_uuid, height)) resolution = COVER_THUMBNAIL_SMALL diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index fc1ed2e375..726e2f9bea 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@

Calibre-Web Tests

-

Start Time: 2024-08-04 21:24:21

+

Start Time: 2024-08-14 19:34:04

-

Stop Time: 2024-08-05 04:56:20

+

Stop Time: 2024-08-15 02:42:49

-

Duration: 6h 17 min

+

Duration: 6h 0 min

@@ -930,43 +930,84 @@

Calibre-Web Tests

- - TestEbookConvertKepubify - 3 - 3 + + _FailedTest + 2 0 0 + 2 0 - Detail + Detail - + -
TestEbookConvertKepubify - test_convert_deactivate
+
_FailedTest - test_ebook_convert_kepubify
- PASS - - - - - - -
TestEbookConvertKepubify - test_convert_only
+ +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertKepubify - test_convert_wrong_excecutable
+
_FailedTest - test_pip_install
+ + +
+ ERROR +
+ + + - PASS @@ -1228,13 +1269,13 @@

Calibre-Web Tests

TestEditBooks - 38 + 37 36 0 0 - 2 + 1 - Detail + Detail @@ -1437,33 +1478,7 @@

Calibre-Web Tests

- - -
TestEditBooks - test_rename_uppercase_lowercase
- - -
- SKIP -
- - - - - - - - - +
TestEditBooks - test_typeahead_author
@@ -1472,7 +1487,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_typeahead_functions
@@ -1481,7 +1496,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_typeahead_language
@@ -1490,7 +1505,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_typeahead_publisher
@@ -1499,7 +1514,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_typeahead_series
@@ -1508,7 +1523,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_typeahead_tag
@@ -1517,7 +1532,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_cb7
@@ -1526,7 +1541,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_cbr
@@ -1535,7 +1550,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_cbt
@@ -1544,7 +1559,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_cbz
@@ -1553,7 +1568,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_epub
@@ -1562,7 +1577,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_fb2
@@ -1571,7 +1586,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_lit
@@ -1580,7 +1595,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_mobi
@@ -1589,7 +1604,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_book_pdf
@@ -1598,7 +1613,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_cbz_coverformats
@@ -1607,7 +1622,7 @@

Calibre-Web Tests

- +
TestEditBooks - test_upload_cover_hdd
@@ -3921,48 +3936,6 @@

Calibre-Web Tests

- - TestPipInstall - 3 - 3 - 0 - 0 - 0 - - Detail - - - - - - - -
TestPipInstall - test_command_start
- - PASS - - - - - - -
TestPipInstall - test_foldername_database_location
- - PASS - - - - - - -
TestPipInstall - test_module_start
- - PASS - - - - - TestReader 8 @@ -3971,13 +3944,13 @@

Calibre-Web Tests

0 1 - Detail + Detail - +
TestReader - test_cb7_reader
@@ -3986,7 +3959,7 @@

Calibre-Web Tests

- +
TestReader - test_comic_MACOS_files
@@ -3995,7 +3968,7 @@

Calibre-Web Tests

- +
TestReader - test_comic_reader
@@ -4004,7 +3977,7 @@

Calibre-Web Tests

- +
TestReader - test_epub_reader
@@ -4013,7 +3986,7 @@

Calibre-Web Tests

- +
TestReader - test_pdf_reader
@@ -4022,7 +3995,7 @@

Calibre-Web Tests

- +
TestReader - test_single_file_comic
@@ -4031,7 +4004,7 @@

Calibre-Web Tests

- +
TestReader - test_sound_listener
@@ -4040,7 +4013,7 @@

Calibre-Web Tests

- +
TestReader - test_txt_reader
@@ -4058,13 +4031,13 @@

Calibre-Web Tests

0 0 - Detail + Detail - +
TestReadOnlyDatabase - test_readonly_path
@@ -4082,13 +4055,13 @@

Calibre-Web Tests

0 0 - Detail + Detail - +
TestRegister - test_forgot_password
@@ -4097,7 +4070,7 @@

Calibre-Web Tests

- +
TestRegister - test_illegal_email
@@ -4106,7 +4079,7 @@

Calibre-Web Tests

- +
TestRegister - test_limit_domain
@@ -4115,7 +4088,7 @@

Calibre-Web Tests

- +
TestRegister - test_register_no_server
@@ -4124,7 +4097,7 @@

Calibre-Web Tests

- +
TestRegister - test_registering_only_email
@@ -4133,7 +4106,7 @@

Calibre-Web Tests

- +
TestRegister - test_registering_user
@@ -4142,7 +4115,7 @@

Calibre-Web Tests

- +
TestRegister - test_registering_user_fail
@@ -4151,7 +4124,7 @@

Calibre-Web Tests

- +
TestRegister - test_user_change_password
@@ -4169,13 +4142,13 @@

Calibre-Web Tests

0 0 - Detail + Detail - +
TestReverseProxy - test_logout
@@ -4184,7 +4157,7 @@

Calibre-Web Tests

- +
TestReverseProxy - test_move_page
@@ -4193,7 +4166,7 @@

Calibre-Web Tests

- +
TestReverseProxy - test_next
@@ -4202,7 +4175,7 @@

Calibre-Web Tests

- +
TestReverseProxy - test_reverse_about
@@ -4220,13 +4193,13 @@

Calibre-Web Tests

0 1 - Detail + Detail - +
TestShelf - test_access_shelf
@@ -4235,7 +4208,7 @@

Calibre-Web Tests

- +
TestShelf - test_add_shelf_from_search
@@ -4244,7 +4217,7 @@

Calibre-Web Tests

- +
TestShelf - test_adv_search_shelf
@@ -4253,7 +4226,7 @@

Calibre-Web Tests

- +
TestShelf - test_arrange_shelf
@@ -4262,7 +4235,7 @@

Calibre-Web Tests

- +
TestShelf - test_create_public_shelf
@@ -4271,7 +4244,7 @@

Calibre-Web Tests

- +
TestShelf - test_create_public_shelf_no_permission
@@ -4280,7 +4253,7 @@

Calibre-Web Tests

- +
TestShelf - test_delete_book_of_shelf
@@ -4289,7 +4262,7 @@

Calibre-Web Tests

- +
TestShelf - test_private_shelf
@@ -4298,7 +4271,7 @@

Calibre-Web Tests

- +
TestShelf - test_public_private_shelf
@@ -4307,7 +4280,7 @@

Calibre-Web Tests

- +
TestShelf - test_public_shelf
@@ -4316,7 +4289,7 @@

Calibre-Web Tests

- +
TestShelf - test_rename_shelf
@@ -4325,7 +4298,7 @@

Calibre-Web Tests

- +
TestShelf - test_shelf_action_non_shelf_edit_role
@@ -4334,7 +4307,7 @@

Calibre-Web Tests

- +
TestShelf - test_shelf_anonymous
@@ -4343,19 +4316,19 @@

Calibre-Web Tests

- +
TestShelf - test_shelf_database_change
- SKIP + SKIP
-