From: Jan Szejko Date: Wed, 7 Jun 2017 12:43:05 +0000 (+0200) Subject: translator in book box X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/89b615b771a8158cdb9f3f9fecd8301686f0da02?hp=f8e76735cc10d9132eb7ca761b0257c50b0c1a10 translator in book box --- diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index db50f3e3c..6527d11d6 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -121,6 +121,17 @@ class Book(models.Model): def author_unicode(self): return self.tag_unicode('author') + def translator(self): + translators = self.extra_info.get('translators') + if not translators: + return None + if len(translators) > 3: + translators = translators[:2] + others = ' i inni' + else: + others = '' + return ', '.join(u'\xa0'.join(reversed(translator.split(', ', 1))) for translator in translators) + others + def save(self, force_insert=False, force_update=False, **kwargs): from sortify import sortify diff --git a/src/catalogue/templates/catalogue/book_short.html b/src/catalogue/templates/catalogue/book_short.html index 0d644093b..35f4a4c61 100644 --- a/src/catalogue/templates/catalogue/book_short.html +++ b/src/catalogue/templates/catalogue/book_short.html @@ -25,6 +25,11 @@
{% if main_link %}{% endif %}{{ book.title }}{% if main_link %}{% endif %}
+ {% if book.translator %} +
+ tłum. {{ book.translator }} +
+ {% endif %}