Mercurial > kallithea
comparison pylons_app/model/forms.py @ 474:a3d9d24acbec celery
Implemented password reset(forms/models/ tasks) and mailing tasks.
Added smtp mailer, configurations, cleaned user model
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 13 Sep 2010 01:27:41 +0200 |
parents | 00f883abdb0c |
children | 9dd38344c466 |
comparison
equal
deleted
inserted
replaced
473:6b934c9607e7 | 474:a3d9d24acbec |
---|---|
100 raise formencode.Invalid(self.message('invalid_password', | 100 raise formencode.Invalid(self.message('invalid_password', |
101 state=State_obj), value, state, | 101 state=State_obj), value, state, |
102 error_dict=self.e_dict) | 102 error_dict=self.e_dict) |
103 if user: | 103 if user: |
104 if user.active: | 104 if user.active: |
105 if user.username == username and check_password(password, | 105 if user.username == username and check_password(password, |
106 user.password): | 106 user.password): |
107 return value | 107 return value |
108 else: | 108 else: |
109 log.warning('user %s not authenticated', username) | 109 log.warning('user %s not authenticated', username) |
110 raise formencode.Invalid(self.message('invalid_password', | 110 raise formencode.Invalid(self.message('invalid_password', |
206 else: | 206 else: |
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 ValidSystemEmail(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 is None: | |
218 raise formencode.Invalid(_("That e-mail address doesn't exist.") , | |
219 value, state) | |
220 finally: | |
221 meta.Session.remove() | |
222 | |
223 return value | |
224 | |
212 #=============================================================================== | 225 #=============================================================================== |
213 # FORMS | 226 # FORMS |
214 #=============================================================================== | 227 #=============================================================================== |
215 class LoginForm(formencode.Schema): | 228 class LoginForm(formencode.Schema): |
216 allow_extra_fields = True | 229 allow_extra_fields = True |
253 email = Email(not_empty=True) | 266 email = Email(not_empty=True) |
254 | 267 |
255 return _UserForm | 268 return _UserForm |
256 | 269 |
257 RegisterForm = UserForm | 270 RegisterForm = UserForm |
258 | 271 |
259 | 272 def PasswordResetForm(): |
273 class _PasswordResetForm(formencode.Schema): | |
274 allow_extra_fields = True | |
275 filter_extra_fields = True | |
276 email = All(ValidSystemEmail(), Email(not_empty=True)) | |
277 return _PasswordResetForm | |
278 | |
260 def RepoForm(edit=False, old_data={}): | 279 def RepoForm(edit=False, old_data={}): |
261 class _RepoForm(formencode.Schema): | 280 class _RepoForm(formencode.Schema): |
262 allow_extra_fields = True | 281 allow_extra_fields = True |
263 filter_extra_fields = False | 282 filter_extra_fields = False |
264 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) | 283 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) |