Exemplo n.º 1
0
def on_user_post_save(sender, instance, created, **kwargs):
    """
    When a User is created, create an API key for them,
    add them to the panda_user group and send them an activation email.
    When a User is saved, update their Datasets' metadata in Solr. 
    """
    # Setup activation
    if created and not kwargs.get('raw', False):
        ApiKey.objects.get_or_create(user=instance)

        panda_users = Group.objects.get(name='panda_user')
        instance.groups.add(panda_users)

        user_profile = UserProfile(user=instance)
        user_profile.generate_activation_key()

        # Expire activation key if they were created with a password
        if instance.has_usable_password():
            user_profile.activation_key_expiration = now()

        user_profile.save()

        # Send an activation email if they were created without a password
        if not instance.has_usable_password():
            user_profile.send_activation_email()
Exemplo n.º 2
0
def on_user_post_save(sender, instance, created, **kwargs):
    """
    When a User is created, create an API key for them,
    add them to the panda_user group and send them an activation email.
    When a User is saved, update their Datasets' metadata in Solr. 
    """
    # Setup activation
    if created and not kwargs.get('raw', False):
        ApiKey.objects.get_or_create(user=instance)

        panda_users = Group.objects.get(name='panda_user')
        instance.groups.add(panda_users)

        user_profile = UserProfile(user=instance)
        user_profile.generate_activation_key()

        # Expire activation key if they were created with a password
        if instance.has_usable_password():
            user_profile.activation_key_expiration=now()

        user_profile.save()

        # Send an activation email if they were created without a password
        if not instance.has_usable_password():
            user_profile.send_activation_email()
Exemplo n.º 3
0
def on_user_post_save(sender, instance, created, **kwargs):
    """
    When a User is created, create an API key for them,
    add them to the panda_user group and send them an activation email.
    When a User is saved, update their Datasets' metadata in Solr. 
    """
    # Setup activation
    if created and not kwargs.get("raw", False):
        ApiKey.objects.get_or_create(user=instance)

        panda_users = Group.objects.get(name="panda_user")
        instance.groups.add(panda_users)

        user_profile = UserProfile(user=instance)
        user_profile.generate_activation_key()
        user_profile.save()

        user_profile.send_activation_email()