Commit 56e51ebd authored by Lukas Burgey's avatar Lukas Burgey

Reenable VO triggers

parent 0b999462
......@@ -84,15 +84,6 @@ class User(AbstractUser):
return self.username
# TODO obsolete right?
# @property
# def deployment_state_items(self):
# items = []
# for dep in self.deployments.all():
# for item in dep.state_items.all():
# items.append(item)
# return items
# we hide deleted keys here
# the full list of ssh keys is self._ssh_keys
@property
......@@ -256,17 +247,18 @@ class User(AbstractUser):
return
local_entitlements = self.vos.instance_of(Entitlement)
remote_entitlements = userinfo.get(self.idp.userinfo_field_entitlements, [])
remote_entitlements = [
Entitlement.extract_name(name)
for name in
userinfo.get(self.idp.userinfo_field_entitlements, [])
]
# check if local_entitlements were removed
for loc_ent in local_entitlements:
if loc_ent.name not in remote_entitlements:
# TRIGGER
# TODO include again
# self.user_changed_entitlement_removed(entitlement)
self.vos.remove(loc_ent)
self.user_changed_vo_removed(loc_ent)
for rem_ent_name in remote_entitlements:
ent = Entitlement.get_entitlement(name=rem_ent_name, idp=self.idp)
......@@ -274,10 +266,9 @@ class User(AbstractUser):
# check if user needs to be in this entitlement
if not self.vos.filter(name=rem_ent_name, idp=self.idp).exists():
LOGGER.info(self.msg('New: %s'), ent)
self.vos.add(ent)
# TODO include again
# self.user_changed_entitlement_added(entitlement)
self.vos.add(ent)
self.user_changed_vo_added(loc_ent)
def update_userinfo_groups(self, userinfo):
if self.idp.userinfo_field_groups is None:
......@@ -289,11 +280,8 @@ class User(AbstractUser):
for group in self.vos.instance_of(Group):
if group.name not in groups:
# TRIGGER
# TODO include again
# self.user_changed_group_removed(group)
self.vos.remove(group)
self.user_changed_vo_removed(group)
# check if groups were added
for group_name in groups:
......@@ -302,10 +290,9 @@ class User(AbstractUser):
# check if user needs to be in this group
if not self.vos.filter(name=group_name, idp=self.idp).exists():
LOGGER.info(self.msg('New: %s'), group)
self.vos.add(group)
# TODO include again
# self.user_changed_group_added(group)
self.user_changed_vo_added(group)
self.vos.add(group)
def update_userinfo_ssh_key(self, userinfo):
......@@ -395,21 +382,21 @@ class User(AbstractUser):
for dep in self.deployments.all():
dep.user_credential_removed(key)
def user_changed_group_added(self, group):
LOGGER.debug('user_changed_group_added: %s %s', self, group)
def user_changed_vo_added(self, vo):
LOGGER.debug('user_changed_vo_added: %s %s', self, vo)
# check if the user has deactivated deployments for this exact group
# check if the user has deactivated deployments for this exact vo
# if yes: reactivate the deployments
for dep in self.deployments.filter(group=group):
LOGGER.debug('user_changed_group_added: need to activate deployment %s', dep)
for dep in self.deployments.filter(vo=vo):
LOGGER.debug('user_changed_vo_added: need to activate deployment %s', dep)
def user_changed_group_removed(self, group):
LOGGER.debug('user_changed_group_removed: %s %s', self, group)
def user_changed_vo_removed(self, vo):
LOGGER.debug('user_changed_vo_removed: %s %s', self, vo)
# check if the user has deployments which need member ship of this group
# check if the user has deployments which need member ship of this vo
# if yes remove them
for dep in self.deployments.filter(group=group):
LOGGER.debug('user_changed_group_removed: need to deactivate deployment %s', dep)
for dep in self.deployments.filter(vo=vo):
LOGGER.debug('user_changed_vo_removed: need to deactivate deployment %s', dep)
class SSHPublicKey(models.Model):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment