From e5841cf284c30bb8e11815a125ea5589c371c540 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 5 Nov 2010 16:39:29 +0000 Subject: [PATCH] Update service groups as they're added to the user, avoiding another costly cronjob --- cronjobs.txt | 1 - sso/models.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cronjobs.txt b/cronjobs.txt index 1fee5a9..c02b6de 100644 --- a/cronjobs.txt +++ b/cronjobs.txt @@ -7,5 +7,4 @@ ROOT=/home/matalok/auth/auth @daily $ROOT/run-cron.py eve_api.cron CorpManagementUpdate > $ROOT/logs/corpman-update.log 2>&1 0 */6 * * * $ROOT/run-cron.py eve_api.cron AllianceUpdate > $ROOT/logs/alliance-update.log 2>&1 @daily $ROOT/run-cron.py eve_proxy.cron ClearStaleCache > $ROOT/logs/cache-clear.log 2>&1 -@daily $ROOT/run-cron.py sso.cron UpdateServicegroups > $ROOT/logs/servicegroup-update.log 2>&1 0 1 * * 5 $ROOT/run-cron.py eve_api.cron CorporationUpdate > $ROOT/logs/corporation-update.log 2>&1 diff --git a/sso/models.py b/sso/models.py index 9520030..4e91384 100644 --- a/sso/models.py +++ b/sso/models.py @@ -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 """