Bugfix Exclude shelfs
This commit is contained in:
@@ -177,11 +177,24 @@ def adv_search_serie(q, include_series_inputs, exclude_series_inputs):
|
|||||||
q = q.filter(not_(db.Books.series.any(db.Series.id == serie)))
|
q = q.filter(not_(db.Books.series.any(db.Series.id == serie)))
|
||||||
return q
|
return q
|
||||||
|
|
||||||
|
|
||||||
def adv_search_shelf(q, include_shelf_inputs, exclude_shelf_inputs):
|
def adv_search_shelf(q, include_shelf_inputs, exclude_shelf_inputs):
|
||||||
q = q.outerjoin(ub.BookShelf, db.Books.id == ub.BookShelf.book_id)\
|
if len(include_shelf_inputs):
|
||||||
.filter(or_(ub.BookShelf.shelf == None, ub.BookShelf.shelf.notin_(exclude_shelf_inputs)))
|
in_shelf = (
|
||||||
if len(include_shelf_inputs) > 0:
|
calibre_db.session.query(ub.BookShelf.id)
|
||||||
q = q.filter(ub.BookShelf.shelf.in_(include_shelf_inputs))
|
.filter(ub.BookShelf.book_id == db.Books.id)
|
||||||
|
.filter(ub.BookShelf.shelf.in_(include_shelf_inputs))
|
||||||
|
.exists()
|
||||||
|
)
|
||||||
|
q = q.filter(in_shelf)
|
||||||
|
if len(exclude_shelf_inputs):
|
||||||
|
ex_shelf = (
|
||||||
|
calibre_db.session.query(ub.BookShelf.id)
|
||||||
|
.filter(ub.BookShelf.book_id == db.Books.id)
|
||||||
|
.filter(ub.BookShelf.shelf.in_(exclude_shelf_inputs))
|
||||||
|
.exists()
|
||||||
|
)
|
||||||
|
q = q.filter(~ex_shelf)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
def extend_search_term(searchterm,
|
def extend_search_term(searchterm,
|
||||||
@@ -341,10 +354,12 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
|||||||
q = adv_search_ratings(q, rating_high, rating_low)
|
q = adv_search_ratings(q, rating_high, rating_low)
|
||||||
|
|
||||||
if description:
|
if description:
|
||||||
|
pass
|
||||||
q = q.filter(db.Books.comments.any(func.lower(db.Comments.text).ilike("%" + description + "%")))
|
q = q.filter(db.Books.comments.any(func.lower(db.Comments.text).ilike("%" + description + "%")))
|
||||||
|
|
||||||
# search custom columns
|
# search custom columns
|
||||||
try:
|
try:
|
||||||
|
pass
|
||||||
q = adv_search_custom_columns(cc, term, q)
|
q = adv_search_custom_columns(cc, term, q)
|
||||||
except AttributeError as ex:
|
except AttributeError as ex:
|
||||||
log.debug_or_exception(ex)
|
log.debug_or_exception(ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user