Ticket #14031: forms.py

File forms.py, 741 bytes (added by harrie.bos@…, 14 years ago)
Line 
1class NewPasswordForm(forms.Form):
2 """
3 A form that lets a user create his/her password
4 """
5 new_password1 = forms.CharField(label=_("New password"), widget=forms.PasswordInput)
6 new_password2 = forms.CharField(label=_("New password confirmation"), widget=forms.PasswordInput)
7
8 def __init__(self, *args, **kwargs):
9 super(NewPasswordForm, self).__init__(*args, **kwargs)
10
11 def clean_new_password2(self):
12 password1 = self.cleaned_data.get('new_password1')
13 password2 = self.cleaned_data.get('new_password2')
14 if password1 and password2:
15 if password1 != password2:
16 raise forms.ValidationError(_("The two password fields didn't match."))
17 return password2
Back to Top