Bugfix advanced search for language
Update results from testrun
This commit is contained in:
parent
bdedec90dd
commit
ec73558b03
17
cps/db.py
17
cps/db.py
|
@ -796,23 +796,24 @@ class CalibreDB():
|
||||||
def speaking_language(self, languages=None, return_all_languages=False, with_count=False, reverse_order=False):
|
def speaking_language(self, languages=None, return_all_languages=False, with_count=False, reverse_order=False):
|
||||||
from . import get_locale
|
from . import get_locale
|
||||||
|
|
||||||
if not languages:
|
if with_count:
|
||||||
if with_count:
|
if not languages:
|
||||||
languages = self.session.query(Languages, func.count('books_languages_link.book'))\
|
languages = self.session.query(Languages, func.count('books_languages_link.book'))\
|
||||||
.join(books_languages_link).join(Books)\
|
.join(books_languages_link).join(Books)\
|
||||||
.filter(self.common_filters(return_all_languages=return_all_languages)) \
|
.filter(self.common_filters(return_all_languages=return_all_languages)) \
|
||||||
.group_by(text('books_languages_link.lang_code')).all()
|
.group_by(text('books_languages_link.lang_code')).all()
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
lang[0].name = isoLanguages.get_language_name(get_locale(), lang[0].lang_code)
|
lang[0].name = isoLanguages.get_language_name(get_locale(), lang[0].lang_code)
|
||||||
return sorted(languages, key=lambda x: x[0].name, reverse=reverse_order)
|
return sorted(languages, key=lambda x: x[0].name, reverse=reverse_order)
|
||||||
else:
|
else:
|
||||||
|
if not languages:
|
||||||
languages = self.session.query(Languages) \
|
languages = self.session.query(Languages) \
|
||||||
.join(books_languages_link) \
|
.join(books_languages_link) \
|
||||||
.join(Books) \
|
.join(Books) \
|
||||||
.filter(self.common_filters(return_all_languages=return_all_languages)) \
|
.filter(self.common_filters(return_all_languages=return_all_languages)) \
|
||||||
.group_by(text('books_languages_link.lang_code')).all()
|
.group_by(text('books_languages_link.lang_code')).all()
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
lang.name = isoLanguages.get_language_name(get_locale(), lang.lang_code)
|
lang.name = isoLanguages.get_language_name(get_locale(), lang.lang_code)
|
||||||
return sorted(languages, key=lambda x: x.name, reverse=reverse_order)
|
return sorted(languages, key=lambda x: x.name, reverse=reverse_order)
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user