X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/232fa239546e5fb2571f246004389f79789c3c86..1d641adedff354dc932c81ae7b1d9f8c41d0b459:/apps/catalogue/models.py?ds=sidebyside diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 7cc77156d..1d0b83b65 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -648,6 +648,24 @@ class Book(models.Model): return self.refresh_theme_counter() return dict((int(k), v) for k, v in self.get__theme_counter_value().iteritems()) + def pretty_title(self, html_links=False): + book = self + names = list(book.tags.filter(category='author')) + + books = [] + while book: + books.append(book) + book = book.parent + names.extend(reversed(books)) + + if html_links: + names = ['%s' % (tag.get_absolute_url(), tag.name) for tag in names] + else: + names = [tag.name for tag in names] + + return ', '.join(names) + + class Fragment(models.Model): text = models.TextField() short_text = models.TextField(editable=False)