Commit 74f9d73c authored by Michal Čihař's avatar Michal Čihař

Restore saving first and last name on registration (issue #93)

parent cb23f64b
......@@ -89,13 +89,6 @@ class RegistrationForm(RegistrationFormUniqueEmail):
self.fields['password2'].label = _('Password (again)')
self.fields['password2'].help_text = _('Repeat the password so we can verify you typed it in correctly.')
def save(self, *args, **kwargs):
new_user = super(RegistrationForm, self).save(*args, **kwargs)
new_user.first_name = self.cleaned_data['first_name']
new_user.last_name = self.cleaned_data['last_name']
new_user.save()
return new_user
def clean_password1(self):
if len(self.cleaned_data['password1']) < 6:
raise forms.ValidationError(_(u'Password needs to have at least six characters.'))
......
......@@ -9,6 +9,7 @@ from django.utils.translation import ugettext_lazy as _, gettext, ugettext_noop
from django.contrib import messages
from django.contrib.auth.models import Group, Permission, User
from django.db.models.signals import post_syncdb
from registration.signals import user_registered
from django.contrib.sites.models import Site
from django.utils import translation
from django.template.loader import render_to_string, get_template_from_string
......@@ -282,3 +283,14 @@ def sync_create_groups(sender, **kwargs):
post_syncdb.connect(sync_create_groups)
post_migrate.connect(sync_create_groups)
def store_user_details(sender, user, request, **kwargs):
'''
Stores user details on registration, here we rely on
validation done by RegistrationForm.
'''
user.first_name = request.POST['first_name']
user.last_name = request.POST['last_name']
user.save()
user_registered.connect(store_user_details)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment