From: Radek Czajka Date: Thu, 9 Feb 2023 12:20:14 +0000 (+0100) Subject: fix X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/6fdea282117c9e066e714d714d3c14efadbca335?ds=sidebyside;hp=94648e7ec0f755a99251bb47389eedf934aa5d3e fix --- diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index b45fc50cf..57dd1f292 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -550,6 +550,8 @@ def content_warning(book): @register.inclusion_tag('catalogue/preview_ad.html', takes_context=True) def preview_ad(context): book = Book.objects.filter(parent=None, preview=True).first() + if book is None: + return {} return { 'accessible': book.is_accessible_to(context['request'].user), 'book': book, @@ -558,6 +560,8 @@ def preview_ad(context): @register.inclusion_tag('catalogue/preview_ad_homepage.html', takes_context=True) def preview_ad_homepage(context): book = Book.objects.filter(parent=None, preview=True).first() + if book is None: + return {} return { 'accessible': book.is_accessible_to(context['request'].user), 'book': book,