diff options
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r-- | ishtar_common/forms_common.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index ce7f81f34..9e29f35e1 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> @@ -31,9 +31,12 @@ import zipfile from django import forms from django.conf import settings +from django.contrib.auth import password_validation from django.contrib.auth.models import User -from django.contrib.auth.forms import AuthenticationForm as AuthAuthenticationForm, \ - UsernameField +from django.contrib.auth.forms import UsernameField, \ + AuthenticationForm as AuthAuthenticationForm, \ + PasswordChangeForm as AuthPasswordChangeForm, \ + SetPasswordForm as AuthSetPasswordForm from django.contrib.contenttypes.models import ContentType from django.core import validators from django.core.cache import cache @@ -149,6 +152,32 @@ class AuthenticationForm(AuthAuthenticationForm): ) +class SetPasswordForm(AuthSetPasswordForm): + new_password1 = forms.CharField( + label=_("New password"), + strip=False, + help_text=password_validation.password_validators_help_text_html(), + widget=forms.PasswordInput(attrs={'autocomplete': 'off', + 'data-toggle': 'password'}), + ) + new_password2 = forms.CharField( + label=_("New password confirmation"), + strip=False, + widget=forms.PasswordInput(attrs={'autocomplete': 'off', + 'data-toggle': 'password'}), + ) + + +class PasswordChangeForm(SetPasswordForm, AuthPasswordChangeForm): + old_password = forms.CharField( + label=_("Old password"), + strip=False, + widget=forms.PasswordInput(attrs={'autofocus': True, 'autocomplete': 'off', + 'data-toggle': 'password'}), + + ) + + class NewItemForm(forms.Form): def __init__(self, *args, **kwargs): self.limits = {} |