Check for readthrough annotation

This commit is contained in:
Mouse Reeve 2021-09-27 13:08:11 -07:00
parent d7a54b0b10
commit 1efe62a70e

View file

@ -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")