mirror of
https://github.com/ae-utbm/sith.git
synced 2025-11-10 05:53:06 +00:00
don't show hidden users in picture identifications
This commit is contained in:
@@ -265,6 +265,17 @@ def sas_notification_callback(notif: Notification):
|
||||
notif.param = str(count)
|
||||
|
||||
|
||||
class PeoplePictureRelationQuerySet(models.QuerySet):
|
||||
def viewable_by(self, user: User) -> Self:
|
||||
if user.is_root or user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||
return self
|
||||
if user.was_subscribed:
|
||||
return self.filter(
|
||||
Q(user_id=user.id) | Q(user__is_subscriber_viewable=True)
|
||||
)
|
||||
return self.filter(user_id=user.id)
|
||||
|
||||
|
||||
class PeoplePictureRelation(models.Model):
|
||||
"""The PeoplePictureRelation class makes the connection between User and Picture."""
|
||||
|
||||
@@ -281,6 +292,8 @@ class PeoplePictureRelation(models.Model):
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
objects = PeoplePictureRelationQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
unique_together = ["user", "picture"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user