From: Radek Czajka Date: Tue, 1 Dec 2026 15:20:56 +0000 (+0100) Subject: Change author sorting X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/5beba008e918dc2d948ac33b5d35769cab90f851 Change author sorting --- diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index a62cac668..a8ff665dd 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -211,7 +211,8 @@ class Book(models.Model): try: author = self.authors().first().sort_key except AttributeError: - author = '' + # Empty authors last + author = '~' self.sort_key_author = author self.cached_author = self.tag_unicode('author') diff --git a/src/catalogue/models/tag.py b/src/catalogue/models/tag.py index d7b02de2b..8bd734d00 100644 --- a/src/catalogue/models/tag.py +++ b/src/catalogue/models/tag.py @@ -226,7 +226,10 @@ class Tag(models.Model): lang = getattr(tag_name, 'lang', None) or settings.LANGUAGE_CODE tag_sort_key = tag_name if category == 'author': - tag_sort_key = ' '.join((tag_name.last_name,) + tag_name.first_names) + tag_sort_key = tag_name.first_names + if tag_name.last_name: + tag_sort_key = (tag_name.last_name,) + tag_sort_key + tag_sort_key = ' '.join(tag_sort_key) tag_name = tag_name.readable() try: