# HG changeset patch # User Marcin Kuzminski # Date 2010-09-20 20:55:55 # Node ID 74b9bed279aec5ea21d7ff2ea59db15b8e7c53f7 # Parent 460ad816820d9ba877e81d1b19599416f4408edf fixed validation of user email in user creation, and editing on admin panel diff --git a/pylons_app/controllers/admin/users.py b/pylons_app/controllers/admin/users.py --- a/pylons_app/controllers/admin/users.py +++ b/pylons_app/controllers/admin/users.py @@ -98,7 +98,10 @@ class UsersController(BaseController): # method='put') # url('user', id=ID) user_model = UserModel() - _form = UserForm(edit=True, old_data={'user_id':id})() + c.user = user_model.get_user(id) + + _form = UserForm(edit=True, old_data={'user_id':id, + 'email':c.user.email})() form_result = {} try: form_result = _form.to_python(dict(request.POST)) @@ -106,7 +109,6 @@ class UsersController(BaseController): h.flash(_('User updated succesfully'), category='success') except formencode.Invalid as errors: - c.user = user_model.get_user(id) return htmlfill.render( render('admin/users/user_edit.html'), defaults=errors.value, diff --git a/pylons_app/model/forms.py b/pylons_app/model/forms.py --- a/pylons_app/model/forms.py +++ b/pylons_app/model/forms.py @@ -212,7 +212,7 @@ class ValidPath(formencode.validators.Fa def UniqSystemEmail(old_data): class _UniqSystemEmail(formencode.validators.FancyValidator): def to_python(self, value, state): - if old_data['email'] != value: + if old_data.get('email') != value: sa = meta.Session try: user = sa.query(User).filter(User.email == value).scalar()