refactor accounts ext forms

remotes/origin/HEAD
Max Yakovenko 8 years ago
parent 5d4b8fabad
commit fa6531c1df
  1. 16
      accounts_ext/forms.py

@ -63,15 +63,13 @@ class RegistrationForm(RegistrationFormUniqueEmail):
def save(self, commit=True):
user = super().save(commit)
profile = Profile.objects.filter(user=user).first()
if profile:
profile.first_name = self.cleaned_data['first_name']
profile.last_name = self.cleaned_data['last_name']
profile.patronymic = self.cleaned_data['patronymic']
profile.save()
else:
logger.error(
msg="User {user_email} missing profile object".format({'user_email': self.cleaned_data['email']})
)
if not profile:
profile = Profile()
profile.first_name = self.cleaned_data['first_name']
profile.last_name = self.cleaned_data['last_name']
profile.patronymic = self.cleaned_data['patronymic']
profile.save()
return user

Loading…
Cancel
Save