From 34d6c8886174c909c87b66ba07faecb318c47a35 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 6 Oct 2021 11:15:17 -0700 Subject: [PATCH] Move privacy levels filter to clearer location --- bookwyrm/models/base_model.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index 6145a1d4..06445a11 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -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)