From c7f02935680f0cac81cd04694f064cd3652821da Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Wed, 14 Aug 2024 18:21:15 +0200 Subject: [PATCH] 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 6558e8d5..41d5ce1d 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 72f01867..2dbea6bc 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 655669ee..00000000 --- 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 bf0b1ab4..d0fdb399 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -25,6 +25,8 @@ + + {% endif %} {% endif %} diff --git a/cps/ub.py b/cps/ub.py index e548cc12..8bc38845 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -311,7 +311,6 @@ class Anonymous(AnonymousUserMixin, UserBase): self.view_settings = data.view_settings self.kobo_only_shelves_sync = data.kobo_only_shelves_sync - def role_admin(self): return False