Améliore le formulaire de mdp K-Fêt
This commit is contained in:
parent
209360f535
commit
aac94afcd0
2 changed files with 31 additions and 18 deletions
|
@ -90,21 +90,34 @@ class AccountPwdForm(forms.Form):
|
|||
label="Mot de passe K-Fêt",
|
||||
required=False,
|
||||
help_text="Le mot de passe doit contenir au moins huit caractères",
|
||||
widget=forms.PasswordInput,
|
||||
widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}),
|
||||
min_length=8,
|
||||
)
|
||||
pwd2 = forms.CharField(
|
||||
label="Confirmer le mot de passe", required=False, widget=forms.PasswordInput
|
||||
label="Confirmer le mot de passe",
|
||||
required=False,
|
||||
widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}),
|
||||
)
|
||||
|
||||
def __init__(self, *args, account=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.account = account
|
||||
|
||||
def clean(self):
|
||||
pwd1 = self.cleaned_data.get("pwd1", "")
|
||||
pwd2 = self.cleaned_data.get("pwd2", "")
|
||||
if len(pwd1) < 8:
|
||||
raise ValidationError("Mot de passe trop court")
|
||||
if pwd1 != pwd2:
|
||||
raise ValidationError("Les mots de passes sont différents")
|
||||
self.add_error("pwd2", "Les mots de passe doivent être identiques !")
|
||||
super().clean()
|
||||
|
||||
def save(self, commit=True):
|
||||
password = self.cleaned_data["pwd1"]
|
||||
self.account.set_password(password)
|
||||
if commit:
|
||||
self.account.save()
|
||||
|
||||
return self.account
|
||||
|
||||
|
||||
class CofForm(forms.ModelForm):
|
||||
def clean_is_cof(self):
|
||||
|
|
|
@ -6,29 +6,29 @@
|
|||
|
||||
{% block title %}
|
||||
{% if account.user == request.user %}
|
||||
Modification de mes informations
|
||||
Modification de mes informations
|
||||
{% else %}
|
||||
{{ account.trigramme }} - Édition
|
||||
{{ account.trigramme }} - Édition
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block header-title %}
|
||||
{% if account.user == request.user %}
|
||||
Modification de mes informations
|
||||
Modification de mes informations
|
||||
{% else %}
|
||||
Édition du compte {{ account.trigramme }}
|
||||
Édition du compte {{ account.trigramme }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
{% if not account.is_team %}
|
||||
{% include "kfet/base_footer.html" %}
|
||||
{% include "kfet/base_footer.html" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
<form action="" method="post" class="form-horizontal" autocomplete="off">
|
||||
{% csrf_token %}
|
||||
{% include 'kfet/form_snippet.html' with form=user_info_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=account_form %}
|
||||
|
@ -36,21 +36,21 @@
|
|||
{% include 'kfet/form_snippet.html' with form=pwd_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=negative_form %}
|
||||
{% if perms.kfet.is_team %}
|
||||
{% include 'kfet/form_authentication_snippet.html' %}
|
||||
{% include 'kfet/form_authentication_snippet.html' %}
|
||||
{% endif %}
|
||||
{% include 'kfet/form_submit_snippet.html' with value="Mettre à jour" %}
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$('#id_authz_overdraft_until').datetimepicker({
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
stepping: 5,
|
||||
locale: 'fr',
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
stepping: 5,
|
||||
locale: 'fr',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
Loading…
Reference in a new issue