From 1efe62a70e8e9c9619d1709fca6adef85326fe9e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 27 Sep 2021 13:08:11 -0700 Subject: [PATCH] Check for readthrough annotation --- bookwyrm/templatetags/bookwyrm_tags.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 07e518ce..e683f9c2 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -87,6 +87,9 @@ def active_shelf(context, book): @register.simple_tag(takes_context=False) def latest_read_through(book, user): """the most recent read activity""" + if hasattr(book, "active_readthroughs"): + return book.active_readthroughs[0] if len(book.active_readthroughs) else None + return ( models.ReadThrough.objects.filter(user=user, book=book, is_active=True) .order_by("-start_date")