X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6f2ae8587bd74b8d5d4f89170ef72209af2f9a1f..85ec4a46392eb3cf34cc0300ed48a8eba976cbc6:/apps/catalogue/templatetags/catalogue_tags.py diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index fa7849538..94753483c 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -61,15 +61,22 @@ def simple_title(tags): return capfirst(', '.join(title)) +def book_stub_title(book): + return ', '.join((book.author, book.title)) + + @register.simple_tag def book_title(book, html_links=False): - names = list(book.tags.filter(category='author')) + try: + names = list(book.tags.filter(category='author')) + except AttributeError: + return book_stub_title(book) books = [] while book: books.append(book) book = book.parent - names.extend(reversed(books[::-1])) + names.extend(reversed(books)) if html_links: names = ['%s' % (tag.get_absolute_url(), tag.name) for tag in names] @@ -253,6 +260,7 @@ def tag_list(tags, choices=None): @register.inclusion_tag('catalogue/folded_tag_list.html') def folded_tag_list(tags, choices=None): + tags = [tag for tag in tags if tag.count] if choices is None: choices = [] some_tags_hidden = False