|
|
@ -473,7 +473,9 @@ def feed_search(term):
|
|
|
|
filter = True
|
|
|
|
filter = True
|
|
|
|
if term:
|
|
|
|
if term:
|
|
|
|
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.like("%" + term + "%")),
|
|
|
|
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.like("%" + term + "%")),
|
|
|
|
|
|
|
|
db.Books.series.any(db.Series.name.like("%" + term + "%")),
|
|
|
|
db.Books.authors.any(db.Authors.name.like("%" + term + "%")),
|
|
|
|
db.Books.authors.any(db.Authors.name.like("%" + term + "%")),
|
|
|
|
|
|
|
|
db.Books.publishers.any(db.Publishers.name.like("%" + term + "%")),
|
|
|
|
db.Books.title.like("%" + term + "%"))).filter(filter).all()
|
|
|
|
db.Books.title.like("%" + term + "%"))).filter(filter).all()
|
|
|
|
entriescount = len(entries) if len(entries) > 0 else 1
|
|
|
|
entriescount = len(entries) if len(entries) > 0 else 1
|
|
|
|
pagination = Pagination(1, entriescount, entriescount)
|
|
|
|
pagination = Pagination(1, entriescount, entriescount)
|
|
|
@ -1089,6 +1091,7 @@ def search():
|
|
|
|
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.like("%" + term + "%")),
|
|
|
|
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.like("%" + term + "%")),
|
|
|
|
db.Books.series.any(db.Series.name.like("%" + term + "%")),
|
|
|
|
db.Books.series.any(db.Series.name.like("%" + term + "%")),
|
|
|
|
db.Books.authors.any(db.Authors.name.like("%" + term + "%")),
|
|
|
|
db.Books.authors.any(db.Authors.name.like("%" + term + "%")),
|
|
|
|
|
|
|
|
db.Books.publishers.any(db.Publishers.name.like("%" + term + "%")),
|
|
|
|
db.Books.title.like("%" + term + "%"))).filter(filter).all()
|
|
|
|
db.Books.title.like("%" + term + "%"))).filter(filter).all()
|
|
|
|
return render_title_template('search.html', searchterm=term, entries=entries)
|
|
|
|
return render_title_template('search.html', searchterm=term, entries=entries)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -1109,12 +1112,14 @@ def advanced_search():
|
|
|
|
|
|
|
|
|
|
|
|
author_name = request.args.get("author_name")
|
|
|
|
author_name = request.args.get("author_name")
|
|
|
|
book_title = request.args.get("book_title")
|
|
|
|
book_title = request.args.get("book_title")
|
|
|
|
|
|
|
|
publisher = request.args.get("publisher")
|
|
|
|
if author_name: author_name = author_name.strip()
|
|
|
|
if author_name: author_name = author_name.strip()
|
|
|
|
if book_title: book_title = book_title.strip()
|
|
|
|
if book_title: book_title = book_title.strip()
|
|
|
|
|
|
|
|
if publisher: publisher = publisher.strip()
|
|
|
|
if include_tag_inputs or exclude_tag_inputs or include_series_inputs or exclude_series_inputs or \
|
|
|
|
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:
|
|
|
|
include_languages_inputs or exclude_languages_inputs or author_name or book_title or publisher:
|
|
|
|
searchterm = []
|
|
|
|
searchterm = []
|
|
|
|
searchterm.extend((author_name, book_title))
|
|
|
|
searchterm.extend((author_name, book_title, publisher))
|
|
|
|
tag_names = db.session.query(db.Tags).filter(db.Tags.id.in_(include_tag_inputs)).all()
|
|
|
|
tag_names = db.session.query(db.Tags).filter(db.Tags.id.in_(include_tag_inputs)).all()
|
|
|
|
searchterm.extend(tag.name for tag in tag_names)
|
|
|
|
searchterm.extend(tag.name for tag in tag_names)
|
|
|
|
# searchterm = " + ".join(filter(None, searchterm))
|
|
|
|
# searchterm = " + ".join(filter(None, searchterm))
|
|
|
@ -1130,7 +1135,8 @@ def advanced_search():
|
|
|
|
searchterm.extend(language.name for language in language_names)
|
|
|
|
searchterm.extend(language.name for language in language_names)
|
|
|
|
searchterm = " + ".join(filter(None, searchterm))
|
|
|
|
searchterm = " + ".join(filter(None, searchterm))
|
|
|
|
q = q.filter(db.Books.authors.any(db.Authors.name.like("%" + author_name + "%")),
|
|
|
|
q = q.filter(db.Books.authors.any(db.Authors.name.like("%" + author_name + "%")),
|
|
|
|
db.Books.title.like("%" + book_title + "%"))
|
|
|
|
db.Books.title.like("%" + book_title + "%"),
|
|
|
|
|
|
|
|
db.Books.publishers.any(db.Publishers.name.like("%" + 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:
|
|
|
|