Ejemplo n.º 1
0
    def create_user(self, email, first_name, last_name, is_social_user=False):
        if not email:
            raise ValueError('Users must have an e-mail address.')

        user = self.model(email=self.normalize_email(email),
                          first_name=first_name,
                          last_name=last_name)

        if not is_social_user:
            set_inactive_user.send(sender=settings.AUTH_USER_MODEL, user=user)

        user.save(using=self._db)

        return user
Ejemplo n.º 2
0
    def save(self, commit=True):
        user = super(forms.ModelForm, self).save(commit=False)

        email = self.cleaned_data.get('email')
        first_name = self.cleaned_data.get('first_name')
        last_name = self.cleaned_data.get('last_name')

        user.email = email
        user.first_name = first_name
        user.last_name = last_name

        set_inactive_user.send(sender=settings.AUTH_USER_MODEL, user=user)
        if commit:
            user.save()

        return user