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,70 +1,102 @@
[
{
"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"
]
]
}
}

View File

@ -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',)