X-Git-Url: https://git.mdrn.pl/cas.git/blobdiff_plain/fccd9926e2f91d7222e7c7a28ad9da92ef081232..37e278e43ece42375352c07d9f04991ef58d992c:/src/accounts/forms.py?ds=inline diff --git a/src/accounts/forms.py b/src/accounts/forms.py new file mode 100644 index 0000000..5dcb842 --- /dev/null +++ b/src/accounts/forms.py @@ -0,0 +1,26 @@ +from django import forms +from django.contrib.auth.models import User as DjangoUser +from django.utils.translation import ugettext_lazy as _ + +class UserBasicForm(forms.ModelForm): + + class Meta: + model = DjangoUser + fields = ('first_name', 'last_name', 'email',) + + +class UserPasswordForm(forms.Form): + + new_password = forms.CharField(widget=forms.PasswordInput(), + label=_("Your new password")) + verifier = forms.CharField(widget=forms.PasswordInput(), + label=_("Repeated password")) + + def clean(self): + if 'verifier' not in self.cleaned_data or 'new_password' not in self.cleaned_data: + return self.cleaned_data + + if self.cleaned_data['verifier'] != self.cleaned_data['new_password']: + raise forms.ValidationError(_("Passwords do not match!")) + + return self.cleaned_data