Merge branch 'aureplop/fix_kfet_perms' into 'master'

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

Closes #168

See merge request !252
This commit is contained in:
Martin Pepin 2017-09-12 22:35:30 +02:00
commit 7d16001ee5

View file

@ -167,10 +167,22 @@ class GroupForm(forms.ModelForm):
name = self.cleaned_data['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:
model = Group
model = Group
fields = ['name', 'permissions']
class AccountNegativeForm(forms.ModelForm):
class Meta:
model = AccountNegative