Refactor the user create, user delete and user set password views.

This commit is contained in:
Roberto Rosario
2016-12-23 03:07:51 -04:00
parent 6c5d0a16ef
commit 116a45f5d2
5 changed files with 154 additions and 189 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import unicode_literals
from django import forms
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
@@ -18,3 +19,11 @@ class PasswordForm(forms.Form):
new_password_2 = forms.CharField(
label=_('Confirm password'), widget=forms.PasswordInput()
)
def clean(self):
password_1 = self.cleaned_data['new_password_1']
password_2 = self.cleaned_data['new_password_2']
if password_1 != password_2:
raise ValidationError('Passwords do not match.')
return self.cleaned_data