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 = ['<a href="%s">%s</a>' % (tag.get_absolute_url(), tag.name) for tag in names]
@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