Refactor the user create, user delete and user set password views.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user