X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/76849e4b3dcc3305edbe86b794b04a0bf4a8467c..e6b4a7031386b8832ee5056d29f8d4ed7c771934:/apps/catalogue/models/book.py?ds=sidebyside diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 64dd498d7..f85cfceca 100644 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -100,6 +100,12 @@ class Book(models.Model): def name(self): return self.title + def language_code(self): + return constants.LANGUAGES_3TO2.get(self.language, self.language) + + def language_name(self): + return dict(settings.LANGUAGES).get(self.language_code(), "") + def book_tag_slug(self): return ('l-' + self.slug)[:120] @@ -406,6 +412,10 @@ class Book(models.Model): for child in self.children.all(): child.parent_cover_changed() + def other_versions(self): + """Find other versions (i.e. in other languages) of the book.""" + return type(self).objects.filter(common_slug=self.common_slug).exclude(pk=self.pk) + def related_info(self): """Keeps info about related objects (tags, media) in cache field.""" if self._related_info is not None: