def save(self, commit=True): data = self.cleaned_data self.instance = UserFactory.create_user(data['email'], data['password']) UserRegistration.objects.create(user=self.instance, is_employer=data['is_employer']) return self.instance
def clean_email(self): data = self.cleaned_data['email'] if User.objects.filter(email=data).count() > 0: raise forms.ValidationError( strings.REGISTRATION_FORM_EMAIL_ALREADY_TAKEN) if UserFactory.user_exists(data): raise forms.ValidationError( strings.REGISTRATION_FORM_USERNAME_COLLISION) return data
def user(self): if self._user is None: self._user = UserFactory.create_user( self.get_email(), constants.USER_PASSWORD) return self._user