mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-12 03:41:19 +00:00
CHeck for current shelves attr before querying for it
This commit is contained in:
parent
995e2c47db
commit
35131262ff
1 changed files with 3 additions and 0 deletions
|
@ -70,6 +70,9 @@ def related_status(notification):
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def active_shelf(context, book):
|
def active_shelf(context, book):
|
||||||
"""check what shelf a user has a book on, if any"""
|
"""check what shelf a user has a book on, if any"""
|
||||||
|
if hasattr(book, "current_shelves"):
|
||||||
|
return book.current_shelves[0]
|
||||||
|
|
||||||
shelf = (
|
shelf = (
|
||||||
models.ShelfBook.objects.filter(
|
models.ShelfBook.objects.filter(
|
||||||
shelf__user=context["request"].user,
|
shelf__user=context["request"].user,
|
||||||
|
|
Loading…
Reference in a new issue