core: put User.group's names in cache

This commit is contained in:
Skia 2018-12-13 18:11:06 +01:00
parent af3e2fb951
commit 82df424146

View File

@ -366,7 +366,11 @@ class User(AbstractBaseUser):
return False return False
if group_id == settings.SITH_GROUP_ROOT_ID and self.is_superuser: if group_id == settings.SITH_GROUP_ROOT_ID and self.is_superuser:
return True return True
return self.groups.filter(name=group_name).exists() return group_name in self.cached_groups_names
@cached_property
def cached_groups_names(self):
return [g.name for g in self.groups.all()]
@cached_property @cached_property
def is_root(self): def is_root(self):