|
|
@ -465,42 +465,39 @@ def get_comic_book(book_id, book_format, page):
|
|
|
|
# ################################### Typeahead ##################################################################
|
|
|
|
# ################################### Typeahead ##################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_authors_json")
|
|
|
|
@web.route("/get_authors_json", methods=['GET'])
|
|
|
|
@login_required_if_no_ano
|
|
|
|
@login_required_if_no_ano
|
|
|
|
def get_authors_json():
|
|
|
|
def get_authors_json():
|
|
|
|
if request.method == "GET":
|
|
|
|
|
|
|
|
return get_typeahead(db.Authors, request.args.get('q'), ('|', ','))
|
|
|
|
return get_typeahead(db.Authors, request.args.get('q'), ('|', ','))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_publishers_json")
|
|
|
|
@web.route("/get_publishers_json", methods=['GET'])
|
|
|
|
@login_required_if_no_ano
|
|
|
|
@login_required_if_no_ano
|
|
|
|
def get_publishers_json():
|
|
|
|
def get_publishers_json():
|
|
|
|
if request.method == "GET":
|
|
|
|
|
|
|
|
return get_typeahead(db.Publishers, request.args.get('q'), ('|', ','))
|
|
|
|
return get_typeahead(db.Publishers, request.args.get('q'), ('|', ','))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_tags_json")
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_tags_json", methods=['GET'])
|
|
|
|
@login_required_if_no_ano
|
|
|
|
@login_required_if_no_ano
|
|
|
|
def get_tags_json():
|
|
|
|
def get_tags_json():
|
|
|
|
if request.method == "GET":
|
|
|
|
|
|
|
|
return get_typeahead(db.Tags, request.args.get('q'),tag_filter=tags_filters())
|
|
|
|
return get_typeahead(db.Tags, request.args.get('q'),tag_filter=tags_filters())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_series_json")
|
|
|
|
@web.route("/get_series_json", methods=['GET'])
|
|
|
|
@login_required_if_no_ano
|
|
|
|
@login_required_if_no_ano
|
|
|
|
def get_series_json():
|
|
|
|
def get_series_json():
|
|
|
|
if request.method == "GET":
|
|
|
|
|
|
|
|
return get_typeahead(db.Series, request.args.get('q'))
|
|
|
|
return get_typeahead(db.Series, request.args.get('q'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_languages_json", methods=['GET', 'POST'])
|
|
|
|
@web.route("/get_languages_json", methods=['GET'])
|
|
|
|
@login_required_if_no_ano
|
|
|
|
@login_required_if_no_ano
|
|
|
|
def get_languages_json():
|
|
|
|
def get_languages_json():
|
|
|
|
if request.method == "GET":
|
|
|
|
query = (request.args.get('q') or '').lower()
|
|
|
|
query = request.args.get('q').lower()
|
|
|
|
|
|
|
|
language_names = isoLanguages.get_language_names(get_locale())
|
|
|
|
language_names = isoLanguages.get_language_names(get_locale())
|
|
|
|
entries_start = [s for key, s in language_names.items() if s.lower().startswith(query.lower())]
|
|
|
|
entries_start = [s for key, s in language_names.items() if s.lower().startswith(query.lower())]
|
|
|
|
if len(entries_start) < 5:
|
|
|
|
if len(entries_start) < 5:
|
|
|
|
|
|
|
|
|
|
|
|
entries = [s for key, s in language_names.items() if query in s.lower()]
|
|
|
|
entries = [s for key, s in language_names.items() if query in s.lower()]
|
|
|
|
entries_start.extend(entries[0:(5-len(entries_start))])
|
|
|
|
entries_start.extend(entries[0:(5-len(entries_start))])
|
|
|
|
entries_start = list(set(entries_start))
|
|
|
|
entries_start = list(set(entries_start))
|
|
|
@ -508,19 +505,18 @@ def get_languages_json():
|
|
|
|
return json_dumps
|
|
|
|
return json_dumps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@web.route("/get_matching_tags", methods=['GET', 'POST'])
|
|
|
|
@web.route("/get_matching_tags", methods=['GET'])
|
|
|
|
@login_required_if_no_ano
|
|
|
|
@login_required_if_no_ano
|
|
|
|
def get_matching_tags():
|
|
|
|
def get_matching_tags():
|
|
|
|
tag_dict = {'tags': []}
|
|
|
|
tag_dict = {'tags': []}
|
|
|
|
if request.method == "GET":
|
|
|
|
|
|
|
|
q = db.session.query(db.Books)
|
|
|
|
q = db.session.query(db.Books)
|
|
|
|
db.session.connection().connection.connection.create_function("lower", 1, lcase)
|
|
|
|
db.session.connection().connection.connection.create_function("lower", 1, lcase)
|
|
|
|
author_input = request.args.get('author_name')
|
|
|
|
author_input = request.args.get('author_name') or ''
|
|
|
|
title_input = request.args.get('book_title')
|
|
|
|
title_input = request.args.get('book_title') or ''
|
|
|
|
include_tag_inputs = request.args.getlist('include_tag')
|
|
|
|
include_tag_inputs = request.args.getlist('include_tag') or ''
|
|
|
|
exclude_tag_inputs = request.args.getlist('exclude_tag')
|
|
|
|
exclude_tag_inputs = request.args.getlist('exclude_tag') or ''
|
|
|
|
include_extension_inputs = request.args.getlist('include_extension')
|
|
|
|
# include_extension_inputs = request.args.getlist('include_extension') or ''
|
|
|
|
exclude_extension_inputs = request.args.getlist('exclude_extension')
|
|
|
|
# exclude_extension_inputs = request.args.getlist('exclude_extension') or ''
|
|
|
|
q = q.filter(db.Books.authors.any(func.lower(db.Authors.name).ilike("%" + author_input + "%")),
|
|
|
|
q = q.filter(db.Books.authors.any(func.lower(db.Authors.name).ilike("%" + author_input + "%")),
|
|
|
|
func.lower(db.Books.title).ilike("%" + title_input + "%"))
|
|
|
|
func.lower(db.Books.title).ilike("%" + title_input + "%"))
|
|
|
|
if len(include_tag_inputs) > 0:
|
|
|
|
if len(include_tag_inputs) > 0:
|
|
|
|