From 0cf9e1033be8df2ddfb432e2e66beb1c9772e04c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Aug 2022 13:26:05 -0700 Subject: [PATCH] Safer display of book descriptions --- bookwyrm/templatetags/book_display_tags.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templatetags/book_display_tags.py b/bookwyrm/templatetags/book_display_tags.py index 9db79f8e4..2ae900c9e 100644 --- a/bookwyrm/templatetags/book_display_tags.py +++ b/bookwyrm/templatetags/book_display_tags.py @@ -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)