active_shelf should always be a reading status shelf

This commit is contained in:
Hugh Rundle 2021-11-20 09:58:34 +11:00
parent a082121930
commit 373cc2c762
No known key found for this signature in database
GPG key ID: CD23D6039184286B

View file

@ -77,7 +77,8 @@ 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] if len(book.current_shelves) else {"book": book}
read_shelves = [s for s in book.current_shelves if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS]
return read_shelves[0] if len(read_shelves) else {"book": book}
shelf = (
models.ShelfBook.objects.filter(