Only call .all once in shelf view

This commit is contained in:
Mouse Reeve 2021-09-27 11:27:46 -07:00
parent cb089ed817
commit 8e8f46ee51
1 changed files with 4 additions and 4 deletions

View File

@ -31,9 +31,9 @@ class Shelf(View):
is_self = user == request.user is_self = user == request.user
if is_self: if is_self:
shelves = user.shelf_set shelves = user.shelf_set.all()
else: else:
shelves = privacy_filter(request.user, user.shelf_set) shelves = privacy_filter(request.user, user.shelf_set).all()
# get the shelf and make sure the logged in user should be able to see it # get the shelf and make sure the logged in user should be able to see it
if shelf_identifier: if shelf_identifier:
@ -53,7 +53,7 @@ class Shelf(View):
models.Edition.viewer_aware_objects(request.user) models.Edition.viewer_aware_objects(request.user)
.filter( .filter(
# privacy is ensured because the shelves are already filtered above # privacy is ensured because the shelves are already filtered above
shelfbook__shelf__in=shelves.all() shelfbook__shelf__in=shelves
) )
.distinct() .distinct()
) )
@ -86,7 +86,7 @@ class Shelf(View):
data = { data = {
"user": user, "user": user,
"is_self": is_self, "is_self": is_self,
"shelves": shelves.all(), "shelves": shelves,
"shelf": shelf, "shelf": shelf,
"books": page, "books": page,
"page_range": paginated.get_elided_page_range( "page_range": paginated.get_elided_page_range(