Python formatting

This commit is contained in:
Mouse Reeve 2021-05-22 18:02:14 -07:00
parent 3d3ab6433e
commit e5ff4ac36d

View file

@ -69,9 +69,14 @@ def related_status(notification):
@register.simple_tag(takes_context=True)
def active_shelf(context, book):
"""check what shelf a user has a book on, if any"""
shelf = models.ShelfBook.objects.filter(
shelf__user=context["request"].user, book__in=book.parent_work.editions.all()
).select_related("book", "shelf").first()
shelf = (
models.ShelfBook.objects.filter(
shelf__user=context["request"].user,
book__in=book.parent_work.editions.all(),
)
.select_related("book", "shelf")
.first()
)
return shelf if shelf else {"book": book}