mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-23 19:37:40 +00:00
Sort authors additionally to series and series_index (Fix #2001)
Sqlalchemy version2 is now a global flag
This commit is contained in:
30
cps/web.py
30
cps/web.py
@@ -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()
|
||||
|
Reference in New Issue
Block a user