From 5afff2231e1a6b209167811c70f101e8d5efa1f3 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 11 Nov 2023 10:43:50 +0100 Subject: [PATCH] Fix for #2743 (read status is no longer implicitly added to advanced search query) --- cps/search.py | 9 +++++---- cps/templates/search_form.html | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cps/search.py b/cps/search.py index 4eee2206..f214b3a8 100644 --- a/cps/search.py +++ b/cps/search.py @@ -217,8 +217,8 @@ def extend_search_term(searchterm, searchterm.extend([_("Rating <= %(rating)s", rating=rating_high)]) if rating_low: searchterm.extend([_("Rating >= %(rating)s", rating=rating_low)]) - if read_status: - searchterm.extend([_("Read Status = %(status)s", status=read_status)]) + if read_status != "Any": + searchterm.extend([_("Read Status = '%(status)s'", status=read_status)]) searchterm.extend(ext for ext in tags['include_extension']) searchterm.extend(ext for ext in tags['exclude_extension']) # handle custom columns @@ -283,7 +283,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): cc_present = True if any(tags.values()) or author_name or book_title or publisher or pub_start or pub_end or rating_low \ - or rating_high or description or cc_present or read_status: + or rating_high or description or cc_present or read_status != "Any": search_term, pub_start, pub_end = extend_search_term(search_term, author_name, book_title, @@ -302,7 +302,8 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): q = q.filter(func.datetime(db.Books.pubdate) > func.datetime(pub_start)) if pub_end: q = q.filter(func.datetime(db.Books.pubdate) < func.datetime(pub_end)) - q = q.filter(adv_search_read_status(read_status)) + if read_status != "Any": + q = q.filter(adv_search_read_status(read_status)) if publisher: q = q.filter(db.Books.publishers.any(func.lower(db.Publishers.name).ilike("%" + publisher + "%"))) q = adv_search_tag(q, tags['include_tag'], tags['exclude_tag']) diff --git a/cps/templates/search_form.html b/cps/templates/search_form.html index 030d8585..cf2fac04 100644 --- a/cps/templates/search_form.html +++ b/cps/templates/search_form.html @@ -41,7 +41,8 @@