From 07f81f56f5a060574a8ffd3ccb1b11859b35a53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rene=CC=81=20Ko=CC=88cher?= Date: Sat, 14 Apr 2012 18:53:18 +0200 Subject: [PATCH] Use natural_keys for initial_data.json / fix auto selected permissions in group editor (lost in 409). --- initial_data.json | 140 ++++++++++++++++++++------------ openslides/participant/forms.py | 5 ++ 2 files changed, 91 insertions(+), 54 deletions(-) diff --git a/initial_data.json b/initial_data.json index dd8af6ebe..79eb6faf7 100644 --- a/initial_data.json +++ b/initial_data.json @@ -1,71 +1,103 @@ [ { - "pk":2, - "model":"auth.group", - "fields":{ - "name":"Beobachter", - "permissions":[ - 28, - 56, - 55, - 73, - 71, - 50 + "pk": 2, + "model": "auth.group", + "fields": { + "name": "Beobachter", + "permissions": [ + [ + "can_see_agenda", + "agenda", + "item" + ], + [ + "can_manage_assignment", + "assignment", + "assignment" + ], + [ + "can_nominate_other", + "assignment", + "assignment" + ] ] } }, { - "pk":3, - "model":"auth.group", - "fields":{ - "name":"Delegierte", - "permissions":[ - 30, - 28, - 56, - 57, - 55, - 72, - 73, - 71, - 50 + "pk": 3, + "model": "auth.group", + "fields": { + "name": "Delegierte", + "permissions": [ + [ + "can_see_agenda", + "agenda", + "item" + ], + [ + "can_manage_assignment", + "assignment", + "assignment" + ], + [ + "can_nominate_other", + "assignment", + "assignment" + ], + [ + "can_nominate_self", + "assignment", + "assignment" + ] ] } }, { - "pk":4, - "model":"auth.group", - "fields":{ - "name":"Tagesleitung", - "permissions":[ - 29, - 30, - 28, - 56, - 58, - 55, - 74, - 72, - 73, - 71, - 51, - 50, - 46 + "pk": 4, + "model": "auth.group", + "fields": { + "name": "Tagesleitung", + "permissions": [ + [ + "can_manage_agenda", + "agenda", + "item" + ], + [ + "can_see_agenda", + "agenda", + "item" + ], + [ + "can_manage_assignment", + "assignment", + "assignment" + ], + [ + "can_nominate_other", + "assignment", + "assignment" + ], + [ + "can_nominate_self", + "assignment", + "assignment" + ] ] } }, { - "pk":5, - "model":"auth.group", - "fields":{ - "name":"Teilnehmerverwaltung", - "permissions":[ - 30, - 28, - 55, - 51, - 50 + "pk": 5, + "model": "auth.group", + "fields": { + "name": "Teilnehmerverwaltung", + "permissions": [ + [ + "can_see_agenda", + "agenda", + "item" + ] ] } } -] +] \ No newline at end of file diff --git a/openslides/participant/forms.py b/openslides/participant/forms.py index 0858ca777..13db3fc3a 100644 --- a/openslides/participant/forms.py +++ b/openslides/participant/forms.py @@ -61,6 +61,11 @@ class ProfileForm(ModelForm, CssClassMixin): class GroupForm(ModelForm, CssClassMixin): permissions = LocalizedModelMultipleChoiceField(queryset=Permission.objects.all()) + def __init__(self, *args, **kwargs): + super(GroupForm, self).__init__(*args, **kwargs) + if kwargs.get('instance', None) is not None: + self.fields['permissions'].initial = [p.pk for p in kwargs['instance'].permissions.all()] + class Meta: model = Group exclude = ('permissions',)