X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/0afa8ce8f8858c875404136d81dfb1645aeac19f..0739e3055a53ad77c1c7de4352750f60453e20c1:/apps/catalogue/models.py?ds=inline diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 54a915227..f201dc237 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -548,6 +548,22 @@ 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):