Safely return if there are no current shelves

This commit is contained in:
Mouse Reeve 2021-09-27 11:29:53 -07:00
parent 8e8f46ee51
commit ba4df5b38b

View file

@ -71,7 +71,7 @@ def related_status(notification):
def active_shelf(context, book):
"""check what shelf a user has a book on, if any"""
if hasattr(book, "current_shelves"):
return book.current_shelves[0]
return book.current_shelves[0] if len(book.current_shelves) else {"book": book}
shelf = (
models.ShelfBook.objects.filter(