def init_mappings(self):
"""Initialize RBAC Mappings.
RBAC Mappings always refer to a (Organization, Team) combination.
In order to reference the Organization instance of this Team, we
are using `self._instance`, which is a proxy object to the upper
level Document.
"""
if not RBACMapping:
return
if self.name == 'Owners':
return
if RBACMapping.objects(org=self._instance.id, team=self.id).only('id'):
raise me.ValidationError(
'RBAC Mappings already initialized for Team %s' % self
)
for perm in ('read', 'read_logs'):
RBACMapping(
org=self._instance.id, team=self.id, permission=perm
).save()
评论列表
文章目录