Fixes duplicted shelves on user view

This commit is contained in:
Mouse Reeve 2022-02-03 18:59:08 -08:00
parent ebc3f14f22
commit 7c0d51ed14

View file

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