Use natural_keys for initial_data.json / fix auto selected permissions in group editor (lost in 409).

This commit is contained in:
René Köcher 2012-04-14 18:53:18 +02:00
parent 50df804010
commit 07f81f56f5
2 changed files with 91 additions and 54 deletions

View File

@ -1,71 +1,103 @@
[ [
{ {
"pk":2, "pk": 2,
"model":"auth.group", "model": "auth.group",
"fields":{ "fields": {
"name":"Beobachter", "name": "Beobachter",
"permissions":[ "permissions": [
28, [
56, "can_see_agenda",
55, "agenda",
73, "item"
71, ],
50 [
"can_manage_assignment",
"assignment",
"assignment"
],
[
"can_nominate_other",
"assignment",
"assignment"
]
] ]
} }
}, },
{ {
"pk":3, "pk": 3,
"model":"auth.group", "model": "auth.group",
"fields":{ "fields": {
"name":"Delegierte", "name": "Delegierte",
"permissions":[ "permissions": [
30, [
28, "can_see_agenda",
56, "agenda",
57, "item"
55, ],
72, [
73, "can_manage_assignment",
71, "assignment",
50 "assignment"
],
[
"can_nominate_other",
"assignment",
"assignment"
],
[
"can_nominate_self",
"assignment",
"assignment"
]
] ]
} }
}, },
{ {
"pk":4, "pk": 4,
"model":"auth.group", "model": "auth.group",
"fields":{ "fields": {
"name":"Tagesleitung", "name": "Tagesleitung",
"permissions":[ "permissions": [
29, [
30, "can_manage_agenda",
28, "agenda",
56, "item"
58, ],
55, [
74, "can_see_agenda",
72, "agenda",
73, "item"
71, ],
51, [
50, "can_manage_assignment",
46 "assignment",
"assignment"
],
[
"can_nominate_other",
"assignment",
"assignment"
],
[
"can_nominate_self",
"assignment",
"assignment"
]
] ]
} }
}, },
{ {
"pk":5, "pk": 5,
"model":"auth.group", "model": "auth.group",
"fields":{ "fields": {
"name":"Teilnehmerverwaltung", "name": "Teilnehmerverwaltung",
"permissions":[ "permissions": [
30, [
28, "can_see_agenda",
55, "agenda",
51, "item"
50 ]
] ]
} }
} }
] ]

View File

@ -61,6 +61,11 @@ class ProfileForm(ModelForm, CssClassMixin):
class GroupForm(ModelForm, CssClassMixin): class GroupForm(ModelForm, CssClassMixin):
permissions = LocalizedModelMultipleChoiceField(queryset=Permission.objects.all()) 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: class Meta:
model = Group model = Group
exclude = ('permissions',) exclude = ('permissions',)