Mercurial > kallithea
comparison pylons_app/model/forms.py @ 489:460ad816820d celery
fixed bug when new repo had no last commiter,
fixed bug when my_account updating information failed, by not uniq email address.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 20 Sep 2010 22:47:20 +0200 |
parents | 9dd38344c466 |
children | 74b9bed279ae |
comparison
equal
deleted
inserted
replaced
488:853b9425742a | 489:460ad816820d |
---|---|
207 msg = _('You need to specify * or ** at the end of path (ie. /tmp/*)') | 207 msg = _('You need to specify * or ** at the end of path (ie. /tmp/*)') |
208 | 208 |
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): | 212 def UniqSystemEmail(old_data): |
213 def to_python(self, value, state): | 213 class _UniqSystemEmail(formencode.validators.FancyValidator): |
214 sa = meta.Session | 214 def to_python(self, value, state): |
215 try: | 215 if old_data['email'] != value: |
216 user = sa.query(User).filter(User.email == value).scalar() | 216 sa = meta.Session |
217 if user: | 217 try: |
218 raise formencode.Invalid(_("That e-mail address is already taken") , | 218 user = sa.query(User).filter(User.email == value).scalar() |
219 value, state) | 219 if user: |
220 finally: | 220 raise formencode.Invalid(_("That e-mail address is already taken") , |
221 meta.Session.remove() | 221 value, state) |
222 | 222 finally: |
223 return value | 223 meta.Session.remove() |
224 | |
225 return value | |
226 | |
227 return _UniqSystemEmail | |
224 | 228 |
225 class ValidSystemEmail(formencode.validators.FancyValidator): | 229 class ValidSystemEmail(formencode.validators.FancyValidator): |
226 def to_python(self, value, state): | 230 def to_python(self, value, state): |
227 sa = meta.Session | 231 sa = meta.Session |
228 try: | 232 try: |
274 else: | 278 else: |
275 password = All(UnicodeString(strip=True, min=8, not_empty=True), ValidPassword) | 279 password = All(UnicodeString(strip=True, min=8, not_empty=True), ValidPassword) |
276 active = StringBoolean(if_missing=False) | 280 active = StringBoolean(if_missing=False) |
277 name = UnicodeString(strip=True, min=3, not_empty=True) | 281 name = UnicodeString(strip=True, min=3, not_empty=True) |
278 lastname = UnicodeString(strip=True, min=3, not_empty=True) | 282 lastname = UnicodeString(strip=True, min=3, not_empty=True) |
279 email = All(Email(not_empty=True), UniqSystemEmail()) | 283 email = All(Email(not_empty=True), UniqSystemEmail(old_data)) |
280 | 284 |
281 return _UserForm | 285 return _UserForm |
282 | 286 |
283 RegisterForm = UserForm | 287 RegisterForm = UserForm |
284 | 288 |