+
+ def clean(self, *args, **kwargs):
+ """
+ Normal cleanup + username generation.
+ """
+ cleaned_data = super(UserCreationForm, self).clean(*args, **kwargs)
+ if cleaned_data.has_key('email'):
+ cleaned_data['username'] = cleaned_data['email']
+ return cleaned_data
+
+ def save(self, commit=True):
+ """
+ Saves the email, first_name and last_name properties, after the normal
+ save behavior is complete.
+ """
+ user = super(InvitedExtendedUserCreationForm, self).save(commit=False)
+ user.renew_token()
+ user.save()
+ logging.info('Created user %s', user)
+ return user