Make sure the user edit form has the complete mail adress in the user account field when opened. Replace confusing id field in form with email field. Editing the email adress of an existing user will still result in an error but that should be fixed soon.
Patch by: Lennard de Rijk
Review by: Pawel Solyga
--- a/app/soc/views/models/user.py Thu Nov 13 19:41:16 2008 +0000
+++ b/app/soc/views/models/user.py Thu Nov 13 20:46:41 2008 +0000
@@ -42,7 +42,7 @@
"""Django form displayed when creating a User.
"""
- id = forms.EmailField(
+ email = forms.EmailField(
label=soc.models.user.User.id.verbose_name,
help_text=soc.models.user.User.id.help_text)
@@ -73,8 +73,8 @@
return link_name
- def clean_id(self):
- form_id = users.User(email=self.cleaned_data.get('id'))
+ def clean_email(self):
+ form_id = users.User(email=self.cleaned_data.get('email'))
key_name = self.data.get('key_name')
if key_name:
user = user_logic.logic.getFromKeyName(key_name)
@@ -88,7 +88,7 @@
and user_logic.logic.getFromFields(email=new_email):
raise forms.ValidationError("This account is already in use.")
- return form_id
+ return self.cleaned_data.get('email')
class EditForm(CreateForm):
@@ -173,12 +173,19 @@
key_fields = dicts.zip(keys, values)
return self.edit(request, page, params=params, **key_fields)
+
+ def _editGet(self, request, entity, form):
+ """See base.View._editGet().
+ """
+ # fill in the email field with the data from the entity
+ form.fields['email'].initial = entity.id.email()
+
def _editPost(self, request, entity, fields):
"""See base.View._editPost().
"""
-
- fields['email'] = fields['id'].email()
+ # fill in the id field with the user created from email
+ fields['id'] = users.User(fields['email'])
view = View()