mirror of
https://github.com/janeczku/calibre-web
synced 2025-11-07 10:43:55 +00:00
Added Publisher and search/advanced search/opds search for publisher
This commit is contained in:
22
cps/web.py
22
cps/web.py
@@ -473,8 +473,10 @@ def feed_search(term):
|
||||
filter = True
|
||||
if term:
|
||||
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.like("%" + term + "%")),
|
||||
db.Books.authors.any(db.Authors.name.like("%" + term + "%")),
|
||||
db.Books.title.like("%" + term + "%"))).filter(filter).all()
|
||||
db.Books.series.any(db.Series.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()
|
||||
entriescount = len(entries) if len(entries) > 0 else 1
|
||||
pagination = Pagination(1, entriescount, entriescount)
|
||||
xml = render_title_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)
|
||||
@@ -1087,9 +1089,10 @@ def search():
|
||||
else:
|
||||
filter = True
|
||||
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.title.like("%" + term + "%"))).filter(filter).all()
|
||||
db.Books.series.any(db.Series.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()
|
||||
return render_title_template('search.html', searchterm=term, entries=entries)
|
||||
else:
|
||||
return render_title_template('search.html', searchterm="")
|
||||
@@ -1109,12 +1112,14 @@ def advanced_search():
|
||||
|
||||
author_name = request.args.get("author_name")
|
||||
book_title = request.args.get("book_title")
|
||||
publisher = request.args.get("publisher")
|
||||
if author_name: author_name = author_name.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 \
|
||||
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.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()
|
||||
searchterm.extend(tag.name for tag in tag_names)
|
||||
# searchterm = " + ".join(filter(None, searchterm))
|
||||
@@ -1130,7 +1135,8 @@ def advanced_search():
|
||||
searchterm.extend(language.name for language in language_names)
|
||||
searchterm = " + ".join(filter(None, searchterm))
|
||||
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:
|
||||
q = q.filter(db.Books.tags.any(db.Tags.id == tag))
|
||||
for tag in exclude_tag_inputs:
|
||||
|
||||
Reference in New Issue
Block a user