Don't display empty shelves on user page

This commit is contained in:
Mouse Reeve 2022-01-30 11:21:56 -08:00
parent a7afd4c47b
commit e674f85d4e

View file

@ -31,12 +31,13 @@ class User(View):
shelf_preview = []
# only show shelves that should be visible
shelves = user.shelf_set
is_self = request.user.id == user.id
if not is_self:
shelves = models.Shelf.privacy_filter(
request.user, privacy_levels=["public", "followers"]
).filter(user=user, books__isnull=False)
else:
shelves = user.shelf_set.filter(books__isnull=False).distinct()
for user_shelf in shelves.all()[:3]:
shelf_preview.append(