Update service groups as they're added to the user, avoiding another costly cronjob

This commit is contained in:
2010-11-05 16:39:29 +00:00
parent f64f31deda
commit e5841cf284
2 changed files with 3 additions and 4 deletions

View File

@@ -107,13 +107,13 @@ class SSOUser(models.Model):
profile, created = SSOUser.objects.get_or_create(user=instance)
@staticmethod
def update_service_groups(sender, instance, created, **kwargs):
if not created:
def update_service_groups(sender, instance, action, **kwargs):
if action in ['post_add', 'post_remove']:
for acc in instance.serviceaccount_set.all():
acc.service.api_class.update_groups(acc.service_uid, instance.groups.all())
signals.post_save.connect(SSOUser.create_user_profile, sender=User)
#signals.post_save.connect(SSOUser.update_service_groups, sender=User)
signals.m2m_changed.connect(SSOUser.update_service_groups, sender=User.groups.through)
class SSOUserNote(models.Model):
""" Notes bound to a user's account. Used to store information regarding the user """