Merge pull request #2263 from bookwyrm-social/safer-book-description

Safer display of book descriptions
This commit is contained in:
Mouse Reeve 2022-08-09 10:21:11 -07:00 committed by GitHub
commit d58282bc37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,12 @@ register = template.Library()
@register.filter(name="book_description") @register.filter(name="book_description")
def get_book_description(book): def get_book_description(book):
"""use the work's text if the book doesn't have it""" """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) @register.simple_tag(takes_context=False)