##// END OF EJS Templates
Added validation for uniq email address
marcink -
r475:9dd38344 celery
parent child Browse files
Show More
@@ -209,6 +209,19 b' class ValidPath(formencode.validators.Fa'
209 209 raise formencode.Invalid(msg, value, state,
210 210 error_dict={'paths_root_path':msg})
211 211
212 class UniqSystemEmail(formencode.validators.FancyValidator):
213 def to_python(self, value, state):
214 sa = meta.Session
215 try:
216 user = sa.query(User).filter(User.email == value).scalar()
217 if user:
218 raise formencode.Invalid(_("That e-mail address is already taken") ,
219 value, state)
220 finally:
221 meta.Session.remove()
222
223 return value
224
212 225 class ValidSystemEmail(formencode.validators.FancyValidator):
213 226 def to_python(self, value, state):
214 227 sa = meta.Session
@@ -263,7 +276,7 b' def UserForm(edit=False, old_data={}):'
263 276 active = StringBoolean(if_missing=False)
264 277 name = UnicodeString(strip=True, min=3, not_empty=True)
265 278 lastname = UnicodeString(strip=True, min=3, not_empty=True)
266 email = Email(not_empty=True)
279 email = All(Email(not_empty=True), UniqSystemEmail())
267 280
268 281 return _UserForm
269 282
General Comments 0
You need to be logged in to leave comments. Login now