def get_or_create_profile(sender, **kwargs): if not kwargs.get('raw'): profile, created = Profile.objects.get_or_create(user=kwargs['instance']) if created: from uchicagohvz.users.tasks import do_sympa_update do_sympa_update.delay(profile.user, 'hvz-chatter', True) do_sympa_update.delay(profile.user, 'zombies', True)
def sympa_update(sender, **kwargs): if not kwargs.get('raw'): from uchicagohvz.users.tasks import do_sympa_update try: old_profile = Profile.objects.get(id=kwargs['instance'].id) except: return new_profile = kwargs['instance'] user = new_profile.user if (not old_profile.subscribe_chatter_listhost) and new_profile.subscribe_chatter_listhost: do_sympa_update.delay(user, 'hvz-chatter', True) elif old_profile.subscribe_chatter_listhost and (not new_profile.subscribe_chatter_listhost): do_sympa_update.delay(user, 'hvz-chatter', False) if (not old_profile.subscribe_zombies_listhost) and new_profile.subscribe_zombies_listhost: do_sympa_update.delay(user, 'zombies', True) elif old_profile.subscribe_zombies_listhost and (not new_profile.subscribe_zombies_listhost): do_sympa_update.delay(user, 'zombies', False)