Example #1
0
def delete_lazy_user(user):
    qs = LazyUser.objects.filter(user=user)
    if qs:
        qs.delete()
        LazyUser.objects.update()
        converted.send(None, user=user)
    # remove lazy sign up backend
    user.backend = None
    user.save()
    assert not is_lazy_user(user)
Example #2
0
def convert_lazy_user(user, username, email, password):
    # TODO: proper error handling of user with the used username (or email,
    # depending what we will use for identification)
    user.username = username
    user.email = email
    user.set_password(password)
    user.backend = None
    user.save()
    LazyUser.objects.filter(user=user).delete()
    converted.send(None, user=user)
    assert is_lazy_user(user) == False
Example #3
0
def delete_lazy_user(user):
    """
    If there is a lazy user associated with the given user, it is deleted.
    """
    qs = LazyUser.objects.filter(user=user)
    if qs:
        qs.delete()
        LazyUser.objects.update()
        converted.send(None, user=user)
    # set default authentication backend
    user.backend = None
    user.save()
    assert not is_lazy_user(user)
    return user
Example #4
0
def delete_lazy_user(user):
    """
    If there is a lazy user associated with the given user, it is deleted.
    """
    qs = LazyUser.objects.filter(user=user)
    if qs:
        qs.delete()
        LazyUser.objects.update()
        converted.send(None, user=user)
    # set default authentication backend
    user.backend = None
    user.save()
    assert not is_lazy_user(user)
    return user
Example #5
0
    def convert(self, form):
        """ Convert a lazy user to a non-lazy one. The form passed
        in is expected to be a ModelForm instance, bound to the user
        to be converted.

        The converted ``User`` object is returned.

        Raises a TypeError if the user is not lazy.
        """
        if not is_lazy_user(form.instance):
            raise NotLazyError('You cannot convert a non-lazy user')

        user = form.save()

        # We need to remove the LazyUser instance assocated with the
        # newly-converted user
        self.filter(user=user).delete()
        converted.send(self, user=user)
        return user
Example #6
0
    def convert(self, form):
        """ Convert a lazy user to a non-lazy one. The form passed
        in is expected to be a ModelForm instance, bound to the user
        to be converted.

        The converted ``User`` object is returned.

        Raises a TypeError if the user is not lazy.
        """
        if not is_lazy_user(form.instance):
            raise NotLazyError('You cannot convert a non-lazy user')

        user = form.save()

        # We need to remove the LazyUser instance assocated with the
        # newly-converted user
        self.filter(user=user).delete()
        converted.send(self, user=user)
        return user
Example #7
0
def convert_lazy_user(user):
    LazyUser.objects.filter(user=user).delete()
    LazyUser.objects.update()
    converted.send(None, user=user)