forked from mirrors/bookwyrm
Move privacy levels filter to clearer location
This commit is contained in:
parent
2307cb2227
commit
34d6c88861
1 changed files with 7 additions and 7 deletions
|
@ -114,7 +114,13 @@ class BookWyrmModel(models.Model):
|
||||||
queryset = queryset.select_subclasses()
|
queryset = queryset.select_subclasses()
|
||||||
|
|
||||||
privacy_levels = privacy_levels or ["public", "unlisted", "followers", "direct"]
|
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:
|
try:
|
||||||
queryset = queryset.filter(deleted=False)
|
queryset = queryset.filter(deleted=False)
|
||||||
except FieldError:
|
except FieldError:
|
||||||
|
@ -126,12 +132,6 @@ class BookWyrmModel(models.Model):
|
||||||
Q(user__blocked_by=viewer) | Q(user__blocks=viewer)
|
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
|
# filter to only privided privacy levels
|
||||||
queryset = queryset.filter(privacy__in=privacy_levels)
|
queryset = queryset.filter(privacy__in=privacy_levels)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue