Merge pull request #1916 from bookwyrm-social/user-view

Fixes duplicted shelves on user view
This commit is contained in:
Mouse Reeve 2022-02-03 19:31:49 -08:00 committed by GitHub
commit da8e07057c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,9 +33,13 @@ class User(View):
# only show shelves that should be visible
is_self = request.user.id == user.id
if not is_self:
shelves = models.Shelf.privacy_filter(
shelves = (
models.Shelf.privacy_filter(
request.user, privacy_levels=["public", "followers"]
).filter(user=user, books__isnull=False)
)
.filter(user=user, books__isnull=False)
.distinct()
)
else:
shelves = user.shelf_set.filter(books__isnull=False).distinct()