Commit 8a199777 authored by Hugo LEVY-FALK's avatar Hugo LEVY-FALK

Ne réinvente pas la roue

parent 4a5fd06a
...@@ -454,23 +454,15 @@ class GroupForm(FormRevMixin, ModelForm): ...@@ -454,23 +454,15 @@ class GroupForm(FormRevMixin, ModelForm):
widget=forms.CheckboxSelectMultiple, widget=forms.CheckboxSelectMultiple,
required=False required=False
) )
superuser = forms.BooleanField(
class Meta: class Meta:
model = User model = User
fields = ['groups'] fields = ['groups', 'is_superuser']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
prefix = kwargs.pop('prefix', self.Meta.model.__name__) prefix = kwargs.pop('prefix', self.Meta.model.__name__)
super(GroupForm, self).__init__(*args, prefix=prefix, **kwargs) super(GroupForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['superuser'].initial = self.instance.is_superuser self.fields['is_superuser'].label = "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): class SchoolForm(FormRevMixin, ModelForm):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment