Change les permissions pour geler/dégeler un compte
This commit is contained in:
parent
0351f6728b
commit
99809209e0
3 changed files with 13 additions and 2 deletions
|
@ -119,6 +119,12 @@ class AccountPwdForm(forms.Form):
|
|||
return self.account
|
||||
|
||||
|
||||
class AccountFrozenForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Account
|
||||
fields = ["is_frozen"]
|
||||
|
||||
|
||||
class CofForm(forms.ModelForm):
|
||||
def clean_is_cof(self):
|
||||
instance = getattr(self, "instance", None)
|
||||
|
|
|
@ -32,6 +32,7 @@ Modification de mes informations
|
|||
{% csrf_token %}
|
||||
{% include 'kfet/form_snippet.html' with form=user_info_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=account_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=frozen_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=group_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=pwd_form %}
|
||||
{% include 'kfet/form_snippet.html' with form=negative_form %}
|
||||
|
|
|
@ -38,6 +38,7 @@ from kfet.config import kfet_config
|
|||
from kfet.decorators import teamkfet_required
|
||||
from kfet.forms import (
|
||||
AccountForm,
|
||||
AccountFrozenForm,
|
||||
AccountNegativeForm,
|
||||
AccountNoTriForm,
|
||||
AccountPwdForm,
|
||||
|
@ -349,10 +350,11 @@ def account_update(request, trigramme):
|
|||
return HttpResponseForbidden
|
||||
|
||||
user_info_form = UserInfoForm(instance=account.user)
|
||||
|
||||
group_form = UserGroupForm(instance=account.user)
|
||||
account_form = AccountForm(instance=account)
|
||||
group_form = UserGroupForm(instance=account.user)
|
||||
frozen_form = AccountFrozenForm(request.POST, instance=account)
|
||||
pwd_form = AccountPwdForm()
|
||||
|
||||
if hasattr(account, "negative"):
|
||||
negative_form = AccountNegativeForm(instance=account.negative)
|
||||
else:
|
||||
|
@ -362,6 +364,7 @@ def account_update(request, trigramme):
|
|||
self_update = request.user == account.user
|
||||
account_form = AccountForm(request.POST, instance=account)
|
||||
group_form = UserGroupForm(request.POST, instance=account.user)
|
||||
frozen_form = AccountFrozenForm(request.POST, instance=account)
|
||||
pwd_form = AccountPwdForm(request.POST, account=account)
|
||||
|
||||
forms = []
|
||||
|
@ -374,6 +377,7 @@ def account_update(request, trigramme):
|
|||
|
||||
if request.user.has_perm("kfet.manage_perms"):
|
||||
forms.append(group_form)
|
||||
forms.append(frozen_form)
|
||||
elif group_form.has_changed():
|
||||
warnings.append("statut d'équipe")
|
||||
|
||||
|
|
Loading…
Reference in a new issue