From 1c5d1e24f769314102e579891fe3b39462839728 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 20 Jul 2024 13:58:53 +0200 Subject: [PATCH 1/3] Update test results --- test/Calibre-Web TestSummary_Linux.html | 124 ++++++------------------ 1 file changed, 32 insertions(+), 92 deletions(-) diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 5b79eaf6..288c7443 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2024-07-11 20:34:31

+

Start Time: 2024-07-18 20:53:44

-

Stop Time: 2024-07-12 03:34:37

+

Stop Time: 2024-07-19 03:48:09

-

Duration: 5h 47 min

+

Duration: 5h 43 min

@@ -2009,7 +2009,7 @@
Traceback (most recent call last):
   File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_metadata.py", line 90, in test_load_metadata
-    elif 'https://amazon.com/' == results[20]['source']:
+    elif len(results)>19 and 'https://amazon.com/' == results[20]['source']:
 IndexError: list index out of range
@@ -2021,11 +2021,11 @@ IndexError: list index out of range - + TestEditBooksOnGdrive 18 - 16 - 2 + 18 + 0 0 0 @@ -2152,31 +2152,11 @@ IndexError: list index out of range - +
TestEditBooksOnGdrive - test_edit_rating
- -
- FAIL -
- - - - + PASS @@ -2208,31 +2188,11 @@ AssertionError: 1 != 0 - +
TestEditBooksOnGdrive - test_watch_metadata
- -
- FAIL -
- - - - + PASS @@ -3340,11 +3300,11 @@ AssertionError: False is not true - + TestLogin 19 - 18 - 1 + 19 + 0 0 0 @@ -3498,31 +3458,11 @@ AssertionError: False is not true - +
TestLogin - test_proxy_login_multi_user
- -
- FAIL -
- - - - + PASS @@ -5674,8 +5614,8 @@ ModuleNotFoundError: No module named 'build_release' Total 499 - 484 - 3 + 487 + 0 2 10   @@ -5705,7 +5645,7 @@ ModuleNotFoundError: No module named 'build_release' Platform - Linux 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2 x86_64 x86_64 + Linux 6.5.0-44-generic #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jun 18 14:36:16 UTC 2 x86_64 x86_64 Basic @@ -5758,14 +5698,14 @@ ModuleNotFoundError: No module named 'build_release' - Flask-Limiter - 3.5.1 + Flask-HTTPAuth + 4.8.0 Basic - Flask-Login - 0.6.3 + Flask-Limiter + 3.5.1 Basic @@ -5891,7 +5831,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestBackupMetadataGdrive @@ -5921,7 +5861,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestCliGdrivedb @@ -5951,7 +5891,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestEbookConvertCalibreGDrive @@ -5981,7 +5921,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestEbookConvertGDriveKepubify @@ -6029,7 +5969,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestEditAuthorsGdrive @@ -6065,7 +6005,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestEditBooksOnGdrive @@ -6107,7 +6047,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestEmbedMetadataGdrive @@ -6137,7 +6077,7 @@ ModuleNotFoundError: No module named 'build_release' PyDrive2 - 1.19.0 + 1.20.0 TestSetupGdrive @@ -6209,7 +6149,7 @@ ModuleNotFoundError: No module named 'build_release' From 12d46d33d9ac861347cb191d3f057cea46aadc46 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 30 Jul 2024 19:20:13 +0200 Subject: [PATCH 2/3] Search custom integer, custom_float in range Search custom bool like read status (unfinished) --- cps/search.py | 32 ++++++++++++++++++++++++++------ cps/templates/search_form.html | 28 ++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/cps/search.py b/cps/search.py index 4ae8a5d7..30fcfd05 100644 --- a/cps/search.py +++ b/cps/search.py @@ -81,13 +81,24 @@ def adv_search_custom_columns(cc, term, q): if custom_end: q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( func.datetime(db.cc_classes[c.id].value) <= func.datetime(custom_end))) + elif c.datatype in ["int", "float"]: + custom_low = term.get('custom_column_' + str(c.id) + '_low') + custom_high = term.get('custom_column_' + str(c.id) + '_high') + if custom_low: + q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( + db.cc_classes[c.id].value >= custom_low)) + if custom_high: + q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( + db.cc_classes[c.id].value <= custom_high)) else: custom_query = term.get('custom_column_' + str(c.id)) - if custom_query != '' and custom_query is not None: - if c.datatype == 'bool': - q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( - db.cc_classes[c.id].value == (custom_query == "True"))) - elif c.datatype == 'int' or c.datatype == 'float': + if c.datatype == 'bool' and custom_query != "Any": + # ToDo: + q = q.filter(coalesce(db.cc_classes[config.config_read_column].value, False) != True) + q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( + db.cc_classes[c.id].value == (custom_query == "True"))) + elif custom_query != '' and custom_query is not None: + if c.datatype == 'int' or c.datatype == 'float': q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( db.cc_classes[c.id].value == custom_query)) elif c.datatype == 'rating': @@ -275,10 +286,19 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): cc_present = True if column_end: search_term.extend(["{} <= {}".format(c.name, - format_date(datetime.strptime(column_end, "%Y-%m-%d").date(), + format_date(datetime.strptime(column_end, "%Y-%m-%d").date(), format='medium') )]) cc_present = True + if c.datatype in ["int", "float"]: + column_low = term.get('custom_column_' + str(c.id) + '_low') + column_high = term.get('custom_column_' + str(c.id) + '_high') + if column_low: + search_term.extend(["{} >= {}".format(c.name, column_low)]) + cc_present = True + if column_high: + search_term.extend(["{} <= {}".format(c.name,column_high)]) + cc_present = True elif term.get('custom_column_' + str(c.id)): search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) cc_present = True diff --git a/cps/templates/search_form.html b/cps/templates/search_form.html index cf2fac04..cdce85a5 100644 --- a/cps/templates/search_form.html +++ b/cps/templates/search_form.html @@ -158,21 +158,41 @@ {% if cc|length > 0 %} {% for c in cc %}
+ {% if c.datatype == 'bool' %} {% endif %} {% if c.datatype == 'int' %} - +
+
+ + +
+
+ + +
+
{% endif %} - {% if c.datatype == 'float' %} - +
+
+ + +
+
+ + +
+
+ {% endif %} {% if c.datatype == 'datetime' %} From e6ccd42f89904c6a6600168bb4946054d1ed6918 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Wed, 31 Jul 2024 19:25:01 +0200 Subject: [PATCH 3/3] Fixed read statu search with linked column in advanced search --- cps/__init__.py | 0 cps/admin.py | 0 cps/redirect.py | 0 cps/search.py | 29 +++++++++++++++++------------ 4 files changed, 17 insertions(+), 12 deletions(-) mode change 100755 => 100644 cps/__init__.py mode change 100755 => 100644 cps/admin.py mode change 100755 => 100644 cps/redirect.py diff --git a/cps/__init__.py b/cps/__init__.py old mode 100755 new mode 100644 diff --git a/cps/admin.py b/cps/admin.py old mode 100755 new mode 100644 diff --git a/cps/redirect.py b/cps/redirect.py old mode 100755 new mode 100644 diff --git a/cps/search.py b/cps/search.py index 30fcfd05..6054ec9e 100644 --- a/cps/search.py +++ b/cps/search.py @@ -24,6 +24,7 @@ from flask_babel import format_date from flask_babel import gettext as _ from sqlalchemy.sql.expression import func, not_, and_, or_, text, true from sqlalchemy.sql.functions import coalesce +from sqlalchemy import exists from . import logger, db, calibre_db, config, ub from .usermanagement import login_required_if_no_ano @@ -92,16 +93,16 @@ def adv_search_custom_columns(cc, term, q): db.cc_classes[c.id].value <= custom_high)) else: custom_query = term.get('custom_column_' + str(c.id)) - if c.datatype == 'bool' and custom_query != "Any": - # ToDo: - q = q.filter(coalesce(db.cc_classes[config.config_read_column].value, False) != True) - q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( - db.cc_classes[c.id].value == (custom_query == "True"))) + if c.datatype == 'bool': + if custom_query != "Any": + if custom_query == "": + q = q.filter(~getattr(db.Books, 'custom_column_' + str(c.id)). + any(db.cc_classes[c.id].value >= 0)) + else: + q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( + db.cc_classes[c.id].value == bool(custom_query == "True"))) elif custom_query != '' and custom_query is not None: - if c.datatype == 'int' or c.datatype == 'float': - q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( - db.cc_classes[c.id].value == custom_query)) - elif c.datatype == 'rating': + if c.datatype == 'rating': q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( db.cc_classes[c.id].value == int(float(custom_query) * 2))) else: @@ -140,10 +141,10 @@ def adv_search_read_status(read_status): db_filter = coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED else: try: - if read_status == "True": - db_filter = db.cc_classes[config.config_read_column].value == True + if read_status == "": + db_filter = coalesce(db.cc_classes[config.config_read_column].value, 2) == 2 else: - db_filter = coalesce(db.cc_classes[config.config_read_column].value, False) != True + db_filter = db.cc_classes[config.config_read_column].value == bool(read_status == "True") except (KeyError, AttributeError, IndexError): log.error("Custom Column No.{} does not exist in calibre database".format(config.config_read_column)) flash(_("Custom Column No.%(column)d does not exist in calibre database", @@ -299,6 +300,10 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): if column_high: search_term.extend(["{} <= {}".format(c.name,column_high)]) cc_present = True + elif c.datatype == "bool": + if term.get('custom_column_' + str(c.id)) != "Any": + search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) + cc_present = True elif term.get('custom_column_' + str(c.id)): search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) cc_present = True