Skip to content

Commit

Permalink
Fix for #2743 (read status is no longer implicitly added to advanced …
Browse files Browse the repository at this point in the history
…search query)
  • Loading branch information
OzzieIsaacs committed Nov 11, 2023
1 parent f78e0ff commit 5afff22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cps/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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'])
Expand Down
3 changes: 2 additions & 1 deletion cps/templates/search_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ <h1 class="{{page}}">{{title}}</h1>
<div class="form-group">
<label for="read_status">{{_('Read Status')}}</label>
<select name="read_status" id="read_status" class="form-control">
<option value="" selected></option>
<option value="Any" selected>{{_('Any')}}</option>
<option value="">{{_('Empty')}}</option>
<option value="True" >{{_('Yes')}}</option>
<option value="False" >{{_('No')}}</option>
</select>
Expand Down

0 comments on commit 5afff22

Please sign in to comment.