From 4a5fd06aceaf7c14001cb8ad4c886c1de96e8765 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 3 May 2018 10:56:21 +0200 Subject: [PATCH] Ajout de superusers --- users/forms.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/users/forms.py b/users/forms.py index 0a17df8b..91e2936a 100644 --- a/users/forms.py +++ b/users/forms.py @@ -454,6 +454,10 @@ class GroupForm(FormRevMixin, ModelForm): widget=forms.CheckboxSelectMultiple, required=False ) + superuser = forms.BooleanField( + label="Superuser", + required=False, + ) class Meta: model = User @@ -462,6 +466,11 @@ class GroupForm(FormRevMixin, ModelForm): def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(GroupForm, self).__init__(*args, prefix=prefix, **kwargs) + self.fields['superuser'].initial = self.instance.is_superuser + + def save(self, *args, **kwargs): + self.instance.is_superuser = self.cleaned_data['superuser'] + return super(GroupForm, self).save(*args, **kwargs) class SchoolForm(FormRevMixin, ModelForm):