Easier to read first-item-or-none list logic
This commit is contained in:
parent
c54609d7fd
commit
a96d027cf3
|
@ -56,14 +56,12 @@ class ReadingStatus(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
# gets the first shelf that indicates a reading status, or None
|
# gets the first shelf that indicates a reading status, or None
|
||||||
current_status_shelfbook = next(
|
shelves = [
|
||||||
iter(
|
|
||||||
s
|
s
|
||||||
for s in book.current_shelves
|
for s in book.current_shelves
|
||||||
if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS
|
if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS
|
||||||
),
|
]
|
||||||
None,
|
current_status_shelfbook = shelves[0] if shelves else None
|
||||||
)
|
|
||||||
|
|
||||||
# checking the referer prevents redirecting back to the modal page
|
# checking the referer prevents redirecting back to the modal page
|
||||||
referer = request.headers.get("Referer", "/")
|
referer = request.headers.get("Referer", "/")
|
||||||
|
|
Loading…
Reference in New Issue