Safer display of book descriptions

This commit is contained in:
Mouse Reeve 2022-08-07 13:26:05 -07:00
parent c8fc907705
commit 0cf9e1033b

View file

@ -8,7 +8,12 @@ register = template.Library()
@register.filter(name="book_description")
def get_book_description(book):
"""use the work's text if the book doesn't have it"""
return book.description or book.parent_work.description
if book.description:
return book.description
if book.parent_work:
# this shoud always be true
return book.parent_work.description
return None
@register.simple_tag(takes_context=False)