diff options
Diffstat (limited to 'django/contrib/auth/forms.py')
| -rw-r--r-- | django/contrib/auth/forms.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index aea52d1f2a..023f9b43be 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -4,6 +4,7 @@ from django.contrib.sites.models import Site from django.template import Context, loader from django.core import validators from django import oldforms +from django.utils.translation import gettext as _ class UserCreationForm(oldforms.Manipulator): "A form that creates a user, with no privileges, from the given username and password." @@ -126,3 +127,18 @@ class PasswordChangeForm(oldforms.Manipulator): "Saves the new password." self.user.set_password(new_data['new_password1']) self.user.save() + +class AdminPasswordChangeForm(oldforms.Manipulator): + "A form used to change the password of a user in the admin interface." + def __init__(self, user): + self.user = user + self.fields = ( + oldforms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True), + oldforms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True, + validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]), + ) + + def save(self, new_data): + "Saves the new password." + self.user.set_password(new_data['password1']) + self.user.save() |
