forked from mirrors/bookwyrm
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
|
||||
def direct_filter(cls, queryset, viewer):
|
||||
"""Override-able filter for "direct" privacy level"""
|
||||
try:
|
||||
return queryset.exclude(
|
||||
~Q(Q(user=viewer) | Q(mention_users=viewer)), privacy="direct"
|
||||
)
|
||||
except FieldError:
|
||||
return queryset.exclude(~Q(user=viewer), privacy="direct")
|
||||
return queryset.exclude(~Q(user=viewer), privacy="direct")
|
||||
|
||||
|
||||
@receiver(models.signals.post_save)
|
||||
|
|
|
@ -207,6 +207,13 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
if isinstance(self, (GeneratedNote, ReviewRating)):
|
||||
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):
|
||||
"""these are app-generated messages about user activity"""
|
||||
|
|
Loading…
Reference in a new issue