|
|
|
@ -360,9 +360,9 @@ def get_sort_function(sort, data):
|
|
|
|
|
if sort == 'old':
|
|
|
|
|
order = [db.Books.timestamp]
|
|
|
|
|
if sort == 'authaz':
|
|
|
|
|
order = [db.Books.author_sort.asc()]
|
|
|
|
|
order = [db.Books.author_sort.asc(), db.Series.name, db.Books.series_index]
|
|
|
|
|
if sort == 'authza':
|
|
|
|
|
order = [db.Books.author_sort.desc()]
|
|
|
|
|
order = [db.Books.author_sort.desc(), db.Series.name.desc(), db.Books.series_index.desc()]
|
|
|
|
|
if sort == 'seriesasc':
|
|
|
|
|
order = [db.Books.series_index.asc()]
|
|
|
|
|
if sort == 'seriesdesc':
|
|
|
|
@ -410,7 +410,10 @@ def render_books_list(data, sort, book_id, page):
|
|
|
|
|
return render_adv_search_results(term, offset, order, config.config_books_per_page)
|
|
|
|
|
else:
|
|
|
|
|
website = data or "newest"
|
|
|
|
|
entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books, True, order)
|
|
|
|
|
entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books, True, order,
|
|
|
|
|
db.books_series_link,
|
|
|
|
|
db.Books.id == db.books_series_link.c.book,
|
|
|
|
|
db.Series)
|
|
|
|
|
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
|
|
|
|
title=_(u"Books"), page=website)
|
|
|
|
|
|
|
|
|
@ -509,8 +512,10 @@ def render_author_books(page, author_id, order):
|
|
|
|
|
flash(_(u"Oops! Selected book title is unavailable. File does not exist or is not accessible"),
|
|
|
|
|
category="error")
|
|
|
|
|
return redirect(url_for("web.index"))
|
|
|
|
|
|
|
|
|
|
author = calibre_db.session.query(db.Authors).get(author_id)
|
|
|
|
|
if constants.sqlalchemy_version2:
|
|
|
|
|
author = calibre_db.session.get(db.Authors, author_id)
|
|
|
|
|
else:
|
|
|
|
|
author = calibre_db.session.query(db.Authors).get(author_id)
|
|
|
|
|
author_name = author.name.replace('|', ',')
|
|
|
|
|
|
|
|
|
|
author_info = None
|
|
|
|
@ -713,7 +718,8 @@ def render_prepare_search_form(cc):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def render_search_results(term, offset=None, order=None, limit=None):
|
|
|
|
|
entries, result_count, pagination = calibre_db.get_search_results(term, offset, order, limit)
|
|
|
|
|
join = db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series
|
|
|
|
|
entries, result_count, pagination = calibre_db.get_search_results(term, offset, order, limit, *join)
|
|
|
|
|
return render_title_template('search.html',
|
|
|
|
|
searchterm=term,
|
|
|
|
|
pagination=pagination,
|
|
|
|
@ -775,8 +781,10 @@ def list_books():
|
|
|
|
|
order = [db.Publishers.name.asc()] if order == "asc" else [db.Publishers.name.desc()]
|
|
|
|
|
join = db.books_publishers_link,db.Books.id == db.books_publishers_link.c.book, db.Publishers
|
|
|
|
|
elif sort == "authors":
|
|
|
|
|
order = [db.Authors.name.asc()] if order == "asc" else [db.Authors.name.desc()]
|
|
|
|
|
join = db.books_authors_link,db.Books.id == db.books_authors_link.c.book, db.Authors
|
|
|
|
|
order = [db.Authors.name.asc(), db.Series.name, db.Books.series_index] if order == "asc" \
|
|
|
|
|
else [db.Authors.name.desc(), db.Series.name.desc(), db.Books.series_index.desc()]
|
|
|
|
|
join = db.books_authors_link, db.Books.id == db.books_authors_link.c.book, db.Authors, \
|
|
|
|
|
db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series
|
|
|
|
|
elif sort == "languages":
|
|
|
|
|
order = [db.Languages.lang_code.asc()] if order == "asc" else [db.Languages.lang_code.desc()]
|
|
|
|
|
join = db.books_languages_link,db.Books.id == db.books_languages_link.c.book, db.Languages
|
|
|
|
@ -793,7 +801,7 @@ def list_books():
|
|
|
|
|
filtered_count = len(books)
|
|
|
|
|
else:
|
|
|
|
|
books = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).all()
|
|
|
|
|
entries = calibre_db.get_checkbox_sorted(books, state, off, limit,order)
|
|
|
|
|
entries = calibre_db.get_checkbox_sorted(books, state, off, limit, order)
|
|
|
|
|
elif search:
|
|
|
|
|
entries, filtered_count, __ = calibre_db.get_search_results(search, off, order, limit, *join)
|
|
|
|
|
else:
|
|
|
|
@ -1242,7 +1250,9 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
|
|
|
|
|
|
|
|
|
cc = get_cc_columns(filter_config_custom_read=True)
|
|
|
|
|
calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
|
|
|
|
|
q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters(True))
|
|
|
|
|
q = calibre_db.session.query(db.Books).outerjoin(db.books_series_link, db.Books.id == db.books_series_link.c.book)\
|
|
|
|
|
.outerjoin(db.Series)\
|
|
|
|
|
.filter(calibre_db.common_filters(True))
|
|
|
|
|
|
|
|
|
|
# parse multiselects to a complete dict
|
|
|
|
|
tags = dict()
|
|
|
|
@ -1587,15 +1597,14 @@ def change_profile(kobo_support, local_oauth_check, oauth_status, translations,
|
|
|
|
|
if to_save.get("password"):
|
|
|
|
|
current_user.password = generate_password_hash(to_save["password"])
|
|
|
|
|
try:
|
|
|
|
|
if to_save.get("allowed_tags", current_user.allowed_tags) != current_user.allowed_tags:
|
|
|
|
|
current_user.allowed_tags = to_save["allowed_tags"].strip()
|
|
|
|
|
if to_save.get("kindle_mail", current_user.kindle_mail) != current_user.kindle_mail:
|
|
|
|
|
current_user.kindle_mail = valid_email(to_save["kindle_mail"])
|
|
|
|
|
if to_save.get("email", current_user.email) != current_user.email:
|
|
|
|
|
current_user.email = check_email(to_save["email"])
|
|
|
|
|
if to_save.get("name", current_user.name) != current_user.name:
|
|
|
|
|
# Query User name, if not existing, change
|
|
|
|
|
current_user.name = check_username(to_save["name"])
|
|
|
|
|
if current_user.role_admin():
|
|
|
|
|
if to_save.get("name", current_user.name) != current_user.name:
|
|
|
|
|
# Query User name, if not existing, change
|
|
|
|
|
current_user.name = check_username(to_save["name"])
|
|
|
|
|
current_user.random_books = 1 if to_save.get("show_random") == "on" else 0
|
|
|
|
|
if to_save.get("default_language"):
|
|
|
|
|
current_user.default_language = to_save["default_language"]
|
|
|
|
@ -1605,10 +1614,16 @@ def change_profile(kobo_support, local_oauth_check, oauth_status, translations,
|
|
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
flash(str(ex), category="error")
|
|
|
|
|
return render_title_template("user_edit.html", content=current_user,
|
|
|
|
|
title=_(u"%(name)s's profile", name=current_user.name), page="me",
|
|
|
|
|
return render_title_template("user_edit.html",
|
|
|
|
|
content=current_user,
|
|
|
|
|
translations=translations,
|
|
|
|
|
profile=1,
|
|
|
|
|
languages=languages,
|
|
|
|
|
title=_(u"%(name)s's profile", name=current_user.name),
|
|
|
|
|
page="me",
|
|
|
|
|
kobo_support=kobo_support,
|
|
|
|
|
registered_oauth=local_oauth_check, oauth_status=oauth_status)
|
|
|
|
|
registered_oauth=local_oauth_check,
|
|
|
|
|
oauth_status=oauth_status)
|
|
|
|
|
|
|
|
|
|
val = 0
|
|
|
|
|
for key, __ in to_save.items():
|
|
|
|
|