|
|
@ -52,6 +52,7 @@ import gdriveutils
|
|
|
|
from redirect import redirect_back
|
|
|
|
from redirect import redirect_back
|
|
|
|
from cps import lm, babel, ub, config, get_locale, language_table, app, db
|
|
|
|
from cps import lm, babel, ub, config, get_locale, language_table, app, db
|
|
|
|
from pagination import Pagination
|
|
|
|
from pagination import Pagination
|
|
|
|
|
|
|
|
import unidecode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
feature_support = dict()
|
|
|
|
feature_support = dict()
|
|
|
@ -873,15 +874,20 @@ def advanced_search():
|
|
|
|
searchterm = " + ".join(filter(None, searchterm))
|
|
|
|
searchterm = " + ".join(filter(None, searchterm))
|
|
|
|
q = q.filter()
|
|
|
|
q = q.filter()
|
|
|
|
if author_name:
|
|
|
|
if author_name:
|
|
|
|
q = q.filter(db.Books.authors.any(db.Authors.name.ilike("%" + author_name + "%")))
|
|
|
|
q = q.filter(db.Books.authors.any(db.or_(db.Authors.name.ilike("%" + author_name + "%"),
|
|
|
|
|
|
|
|
db.Authors.name.ilike("%" + unidecode.unidecode(author_name)
|
|
|
|
|
|
|
|
+ "%"))))
|
|
|
|
if book_title:
|
|
|
|
if book_title:
|
|
|
|
q = q.filter(db.Books.title.ilike("%" + book_title + "%"))
|
|
|
|
q = q.filter(db.or_(db.Books.title.ilike("%" + book_title + "%"),
|
|
|
|
|
|
|
|
db.Books.title.ilike("%" + unidecode.unidecode(book_title) + "%")))
|
|
|
|
if pub_start:
|
|
|
|
if pub_start:
|
|
|
|
q = q.filter(db.Books.pubdate >= pub_start)
|
|
|
|
q = q.filter(db.Books.pubdate >= pub_start)
|
|
|
|
if pub_end:
|
|
|
|
if pub_end:
|
|
|
|
q = q.filter(db.Books.pubdate <= pub_end)
|
|
|
|
q = q.filter(db.Books.pubdate <= pub_end)
|
|
|
|
if publisher:
|
|
|
|
if publisher:
|
|
|
|
q = q.filter(db.Books.publishers.any(db.Publishers.name.ilike("%" + publisher + "%")))
|
|
|
|
q = q.filter(db.Books.publishers.any(db.or_(db.Publishers.name.ilike("%" + publisher + "%"),
|
|
|
|
|
|
|
|
db.Publishers.name.ilike("%" + unidecode.unidecode(publisher)
|
|
|
|
|
|
|
|
+ "%"),)))
|
|
|
|
for tag in include_tag_inputs:
|
|
|
|
for tag in include_tag_inputs:
|
|
|
|
q = q.filter(db.Books.tags.any(db.Tags.id == tag))
|
|
|
|
q = q.filter(db.Books.tags.any(db.Tags.id == tag))
|
|
|
|
for tag in exclude_tag_inputs:
|
|
|
|
for tag in exclude_tag_inputs:
|
|
|
@ -904,7 +910,9 @@ def advanced_search():
|
|
|
|
rating_low = int(rating_low) * 2
|
|
|
|
rating_low = int(rating_low) * 2
|
|
|
|
q = q.filter(db.Books.ratings.any(db.Ratings.rating >= rating_low))
|
|
|
|
q = q.filter(db.Books.ratings.any(db.Ratings.rating >= rating_low))
|
|
|
|
if description:
|
|
|
|
if description:
|
|
|
|
q = q.filter(db.Books.comments.any(db.Comments.text.ilike("%" + description + "%")))
|
|
|
|
q = q.filter(db.Books.comments.any(db.or_(db.Comments.text.ilike("%" + description + "%"),
|
|
|
|
|
|
|
|
db.Comments.text.ilike("%" + unidecode.unidecode(description)
|
|
|
|
|
|
|
|
+ "%"))))
|
|
|
|
|
|
|
|
|
|
|
|
# search custom culumns
|
|
|
|
# search custom culumns
|
|
|
|
for c in cc:
|
|
|
|
for c in cc:
|
|
|
@ -919,7 +927,8 @@ def advanced_search():
|
|
|
|
db.cc_classes[c.id].value == custom_query))
|
|
|
|
db.cc_classes[c.id].value == custom_query))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
q = q.filter(getattr(db.Books, 'custom_column_'+str(c.id)).any(
|
|
|
|
q = q.filter(getattr(db.Books, 'custom_column_'+str(c.id)).any(
|
|
|
|
db.cc_classes[c.id].value.ilike("%" + custom_query + "%")))
|
|
|
|
db.or_(db.cc_classes[c.id].value.ilike("%" + custom_query + "%"),
|
|
|
|
|
|
|
|
db.cc_classes[c.id].value.ilike("%" + unidecode.unidecode(custom_query) + "%"))))
|
|
|
|
q = q.all()
|
|
|
|
q = q.all()
|
|
|
|
ids = list()
|
|
|
|
ids = list()
|
|
|
|
for element in q:
|
|
|
|
for element in q:
|
|
|
|