X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/8159cf8992d55a28ee79f687ab87f332664ff155..b79a206b79a5e805ad06f9103977e19589b66758:/src/catalogue/models/book.py 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