Easier to read first-item-or-none list logic

This commit is contained in:
Mouse Reeve 2021-09-22 16:16:53 -07:00
parent c54609d7fd
commit a96d027cf3

View file

@ -56,14 +56,12 @@ class ReadingStatus(View):
)
# gets the first shelf that indicates a reading status, or None
current_status_shelfbook = next(
iter(
s
for s in book.current_shelves
if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS
),
None,
)
shelves = [
s
for s in book.current_shelves
if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS
]
current_status_shelfbook = shelves[0] if shelves else None
# checking the referer prevents redirecting back to the modal page
referer = request.headers.get("Referer", "/")