Messages become harder to miss.
[cas.git] / src / accounts / forms.py
1 from django import forms
2 from django.contrib.auth.models import User as DjangoUser
3 from django.utils.translation import ugettext_lazy as _
4
5 class UserBasicForm(forms.ModelForm):
6
7     class Meta:
8         model = DjangoUser
9         fields = ('first_name', 'last_name', 'email',)
10
11
12 class UserPasswordForm(forms.Form):
13
14     new_password = forms.CharField(widget=forms.PasswordInput(),
15                         label=_("Your new password"))
16     verifier = forms.CharField(widget=forms.PasswordInput(),
17                         label=_("Repeated password"))
18
19     def clean(self):
20         if 'verifier' not in self.cleaned_data or 'new_password' not in self.cleaned_data:
21             return self.cleaned_data
22
23         if self.cleaned_data['verifier'] != self.cleaned_data['new_password']:
24             raise forms.ValidationError(_("Passwords do not match!"))
25
26         return self.cleaned_data