Move privacy levels filter to clearer location

This commit is contained in:
Mouse Reeve 2021-10-06 11:15:17 -07:00
parent 2307cb2227
commit 34d6c88861

View file

@ -114,7 +114,13 @@ class BookWyrmModel(models.Model):
queryset = queryset.select_subclasses()
privacy_levels = privacy_levels or ["public", "unlisted", "followers", "direct"]
# if there'd a deleted field, exclude deleted items
# you can't see followers only or direct messages if you're not logged in
if viewer.is_anonymous:
privacy_levels = [
p for p in privacy_levels if not p in ["followers", "direct"]
]
# if there's a deleted field, exclude deleted items
try:
queryset = queryset.filter(deleted=False)
except FieldError:
@ -126,12 +132,6 @@ class BookWyrmModel(models.Model):
Q(user__blocked_by=viewer) | Q(user__blocks=viewer)
)
# you can't see followers only or direct messages if you're not logged in
if viewer.is_anonymous:
privacy_levels = [
p for p in privacy_levels if not p in ["followers", "direct"]
]
# filter to only privided privacy levels
queryset = queryset.filter(privacy__in=privacy_levels)