sas: simplify and optimize permissions for SAS images

This commit is contained in:
Antoine Bartuccio 2019-09-15 16:43:17 +02:00
parent 1f86827e46
commit 8330e1eaf2
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -71,16 +71,11 @@ class Picture(SithFile):
return False return False
def can_be_edited_by(self, user): def can_be_edited_by(self, user):
# file = SithFile.objects.filter(id=self.id).first() return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)
return user.is_in_group(
settings.SITH_GROUP_SAS_ADMIN_ID
) # or user.can_edit(file)
def can_be_viewed_by(self, user): def can_be_viewed_by(self, user):
# file = SithFile.objects.filter(id=self.id).first() # SAS pictures are visible to old subscribers
return self.can_be_edited_by(user) or ( return self.is_in_sas and self.is_moderated and user.was_subscribed
self.is_in_sas and self.is_moderated and user.was_subscribed
) # or user.can_view(file)
def get_download_url(self): def get_download_url(self):
return reverse("sas:download", kwargs={"picture_id": self.id}) return reverse("sas:download", kwargs={"picture_id": self.id})