K-Fêt' groups edits don't remove non-kfet app permissions.

Fixes #168.
This commit is contained in:
Aurélien Delobelle 2017-09-11 16:42:14 +02:00
parent faed7bff73
commit 9e61887868

View file

@ -167,10 +167,22 @@ class GroupForm(forms.ModelForm):
name = self.cleaned_data['name'] name = self.cleaned_data['name']
return 'K-Fêt %s' % name return 'K-Fêt %s' % name
def clean_permissions(self):
kfet_perms = self.cleaned_data['permissions']
# TODO: With Django >=1.11, the QuerySet method 'difference' can be used.
# other_groups = self.instance.permissions.difference(
# self.fields['permissions'].queryset
# )
other_perms = self.instance.permissions.exclude(
pk__in=[p.pk for p in self.fields['permissions'].queryset],
)
return list(kfet_perms) + list(other_perms)
class Meta: class Meta:
model = Group model = Group
fields = ['name', 'permissions'] fields = ['name', 'permissions']
class AccountNegativeForm(forms.ModelForm): class AccountNegativeForm(forms.ModelForm):
class Meta: class Meta:
model = AccountNegative model = AccountNegative