User viewer aware objects for book page

Plus other refactors for that view
This commit is contained in:
Mouse Reeve
2021-09-27 11:13:47 -07:00
parent 6d06edc2c7
commit 995e2c47db
2 changed files with 30 additions and 18 deletions

View File

@ -49,10 +49,14 @@ class Shelf(View):
FakeShelf = namedtuple(
"Shelf", ("identifier", "name", "user", "books", "privacy")
)
books = models.Edition.viewer_aware_objects(request.user).filter(
# privacy is ensured because the shelves are already filtered above
shelfbook__shelf__in=shelves.all()
).distinct()
books = (
models.Edition.viewer_aware_objects(request.user)
.filter(
# privacy is ensured because the shelves are already filtered above
shelfbook__shelf__in=shelves.all()
)
.distinct()
)
shelf = FakeShelf("all", _("All books"), user, books, "public")
if is_api_request(request):