mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-10 17:25:35 +00:00
User override in child class instead of if/else for privacy_filter
This commit is contained in:
parent
97cc129478
commit
68b6b1fbae
2 changed files with 8 additions and 6 deletions
|
@ -167,12 +167,7 @@ class BookWyrmModel(models.Model):
|
||||||
@classmethod
|
@classmethod
|
||||||
def direct_filter(cls, queryset, viewer):
|
def direct_filter(cls, queryset, viewer):
|
||||||
"""Override-able filter for "direct" privacy level"""
|
"""Override-able filter for "direct" privacy level"""
|
||||||
try:
|
return queryset.exclude(~Q(user=viewer), privacy="direct")
|
||||||
return queryset.exclude(
|
|
||||||
~Q(Q(user=viewer) | Q(mention_users=viewer)), privacy="direct"
|
|
||||||
)
|
|
||||||
except FieldError:
|
|
||||||
return queryset.exclude(~Q(user=viewer), privacy="direct")
|
|
||||||
|
|
||||||
|
|
||||||
@receiver(models.signals.post_save)
|
@receiver(models.signals.post_save)
|
||||||
|
|
|
@ -207,6 +207,13 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
if isinstance(self, (GeneratedNote, ReviewRating)):
|
if isinstance(self, (GeneratedNote, ReviewRating)):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def direct_filter(cls, queryset, viewer):
|
||||||
|
"""Override-able filter for "direct" privacy level"""
|
||||||
|
return queryset.exclude(
|
||||||
|
~Q(Q(user=viewer) | Q(mention_users=viewer)), privacy="direct"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GeneratedNote(Status):
|
class GeneratedNote(Status):
|
||||||
"""these are app-generated messages about user activity"""
|
"""these are app-generated messages about user activity"""
|
||||||
|
|
Loading…
Reference in a new issue