Show More
@@ -209,6 +209,19 b' class ValidPath(formencode.validators.Fa' | |||||
209 | raise formencode.Invalid(msg, value, state, |
|
209 | raise formencode.Invalid(msg, value, state, | |
210 | error_dict={'paths_root_path':msg}) |
|
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 | class ValidSystemEmail(formencode.validators.FancyValidator): |
|
225 | class ValidSystemEmail(formencode.validators.FancyValidator): | |
213 | def to_python(self, value, state): |
|
226 | def to_python(self, value, state): | |
214 | sa = meta.Session |
|
227 | sa = meta.Session | |
@@ -263,7 +276,7 b' def UserForm(edit=False, old_data={}):' | |||||
263 | active = StringBoolean(if_missing=False) |
|
276 | active = StringBoolean(if_missing=False) | |
264 | name = UnicodeString(strip=True, min=3, not_empty=True) |
|
277 | name = UnicodeString(strip=True, min=3, not_empty=True) | |
265 | lastname = UnicodeString(strip=True, min=3, not_empty=True) |
|
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 | return _UserForm |
|
281 | return _UserForm | |
269 |
|
282 |
General Comments 0
You need to be logged in to leave comments.
Login now