Better usage of cache for group retrieval

This commit is contained in:
Maréchal | Thomas
2023-04-21 00:00:45 +02:00
committed by maréchal
parent 96dede5077
commit aa7ec7f1f7
4 changed files with 166 additions and 134 deletions

View File

@@ -340,9 +340,10 @@ class Poster(models.Model):
raise ValidationError(_("Begin date should be before end date"))
def is_owned_by(self, user):
return user.is_in_group(
settings.SITH_GROUP_COM_ADMIN_ID
) or Club.objects.filter(id__in=user.clubs_with_rights)
return (
user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
or len(user.clubs_with_rights) > 0
)
def can_be_moderated_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)