1. Waldemar Kornewald
  2. djangotoolbox

Commits

d3f3nd3r  committed cd35769

rename permissions to user_permissions

  • Participants
  • Parent commits 6118b97
  • Branches default

Comments (0)

Files changed (1)

File djangotoolbox/admin.py

View file
  • Ignore whitespace
 
 
 class NonrelPermissionUserForm(UserForm):
-    permissions = forms.MultipleChoiceField(required=False)
+    user_permissions = forms.MultipleChoiceField(required=False)
     groups = forms.MultipleChoiceField(required=False)
     
     def __init__(self, *args, **kwargs):
         super(NonrelPermissionUserForm, self).__init__(*args, **kwargs)
 
-        self.fields['permissions'] = forms.MultipleChoiceField(required=False)
+        self.fields['user_permissions'] = forms.MultipleChoiceField(required=False)
         self.fields['groups'] = forms.MultipleChoiceField(required=False)
         
         permissions_objs = Permission.objects.all().order_by('name')
-        choices = list ()
+        choices = []
         for perm_obj in permissions_objs:
             choices.append([perm_obj.id, perm_obj.name])
-        self.fields['permissions'].choices = choices
+        self.fields['user_permissions'].choices = choices
         
         group_objs = Group.objects.all()
-        choices = list ()
+        choices = []
         for group_obj in group_objs:
             choices.append([group_obj.id, group_obj.name])
         self.fields['groups'].choices = choices
         try:
             user_perm_list = UserPermissionList.objects.get(
                 user=kwargs['instance'])
-            self.fields['permissions'].initial = user_perm_list.fk_list
+            self.fields['user_permissions'].initial = user_perm_list.fk_list
         except (UserPermissionList.DoesNotExist, KeyError):
-            self.fields['permissions'].initial = list()
+            self.fields['user_permissions'].initial = list()
             
         try:
             user_group_list = GroupList.objects.get(
     def save_model(self, request, obj, form, change):
         super(NonrelPermissionCustomUserAdmin, self).save_model(request, obj, form, change)
 
-        if len(form.cleaned_data['permissions']) > 0:
-            permissions = [Permission.objects.filter(
-                id__in=form.cleaned_data['permissions']).order_by('name')]
+        if len(form.cleaned_data['user_permissions']) > 0:
+            permissions = list(Permission.objects.filter(
+                id__in=form.cleaned_data['user_permissions']).order_by('name'))
         else:
             permissions = []
 
         update_permissions_user(permissions, obj)
 
         if len(form.cleaned_data['groups']) > 0:
-            groups = [Group.objects.filter(
-                id__in=form.cleaned_data['groups'])]
+            groups = list(Group.objects.filter(
+                id__in=form.cleaned_data['groups']))
         else:
             groups = []
 
         super(CustomGroupAdmin, self).save_model(request, obj, form, change)
 
         if len(form.cleaned_data['permissions']) > 0:
-            permissions = [Permission.objects.filter(
-                id__in=form.cleaned_data['permissions']).order_by('name')]
+            permissions = list(Permission.objects.filter(
+                id__in=form.cleaned_data['permissions']).order_by('name'))
         else:
             permissions = []