Changeset - 74b9bed279ae
[Not reviewed]
celery
0 2 0
Marcin Kuzminski - 15 years ago 2010-09-20 22:55:55
marcin@python-works.com
fixed validation of user email in user creation, and editing on admin panel
2 files changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/admin/users.py
Show inline comments
 
@@ -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,
pylons_app/model/forms.py
Show inline comments
 
@@ -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()
0 comments (0 inline, 0 general)