1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-29 03:20:30 +00:00

Search for read status

This commit is contained in:
Ozzieisaacs 2020-12-27 18:59:33 +01:00
parent 1a83bddf8c
commit 1e351eb01d
2 changed files with 31 additions and 2 deletions

View File

@ -31,6 +31,14 @@
</div>
</div>
</div>
<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="True" >{{_('Yes')}}</option>
<option value="False" >{{_('No')}}</option>
</select>
</div>
<label for="include_tag">{{_('Tags')}}</label>
<div class="form-group" id="tag">
<div class="btn-toolbar btn-toolbar-lg" data-toggle="buttons">

View File

@ -618,7 +618,8 @@ def render_read_books(page, are_read, as_xml=False, order=None):
db_filter = and_(ub.ReadBook.user_id == int(current_user.id),
ub.ReadBook.read_status == ub.ReadBook.STATUS_FINISHED)
else:
db_filter = coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED
db_filter = and_(ub.ReadBook.user_id == int(current_user.id),
coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED)
entries, random, pagination = calibre_db.fill_indexpage(page, 0,
db.Books,
db_filter,
@ -1030,6 +1031,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
rating_low = term.get("ratinghigh")
rating_high = term.get("ratinglow")
description = term.get("comment")
read_status = term.get("read_status")
if author_name:
author_name = author_name.strip().lower().replace(',', '|')
if book_title:
@ -1047,7 +1049,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
if include_tag_inputs or exclude_tag_inputs or include_series_inputs or exclude_series_inputs or \
include_languages_inputs or exclude_languages_inputs 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 \
include_extension_inputs or exclude_extension_inputs:
include_extension_inputs or exclude_extension_inputs or read_status:
searchterm.extend((author_name.replace('|', ','), book_title, publisher))
if pub_start:
try:
@ -1076,6 +1078,8 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
searchterm.extend([_(u"Rating <= %(rating)s", rating=rating_high)])
if rating_low:
searchterm.extend([_(u"Rating >= %(rating)s", rating=rating_low)])
if read_status:
searchterm.extend([_(u"Read Status = %(status)s", status=read_status)])
searchterm.extend(ext for ext in include_extension_inputs)
searchterm.extend(ext for ext in exclude_extension_inputs)
# handle custom columns
@ -1092,6 +1096,23 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
q = q.filter(db.Books.pubdate >= pub_start)
if pub_end:
q = q.filter(db.Books.pubdate <= pub_end)
if read_status:
if config.config_read_column:
if read_status=="True":
q = q.join(db.cc_classes[config.config_read_column], isouter=True) \
.filter(db.cc_classes[config.config_read_column].value == True)
else:
q = q.join(db.cc_classes[config.config_read_column], isouter=True) \
.filter(coalesce(db.cc_classes[config.config_read_column].value, False) != True)
else:
if read_status == "True":
q = q.join(ub.ReadBook, db.Books.id==ub.ReadBook.book_id, isouter=True)\
.filter(ub.ReadBook.user_id == int(current_user.id),
ub.ReadBook.read_status == ub.ReadBook.STATUS_FINISHED)
else:
q = q.join(ub.ReadBook, db.Books.id == ub.ReadBook.book_id, isouter=True) \
.filter(ub.ReadBook.user_id == int(current_user.id),
coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED)
if publisher:
q = q.filter(db.Books.publishers.any(func.lower(db.Publishers.name).ilike("%" + publisher + "%")))
for tag in include_tag_inputs: