2
0
Эх сурвалжийг харах

Fix ordering of group and user fields in ObjectPermission admin

Jeremy Stretch 5 жил өмнө
parent
commit
5d4cc5bf3d
1 өөрчлөгдсөн 7 нэмэгдсэн , 1 устгасан
  1. 7 1
      netbox/users/admin.py

+ 7 - 1
netbox/users/admin.py

@@ -90,7 +90,9 @@ class ObjectPermissionForm(forms.ModelForm):
         model = ObjectPermission
         exclude = []
         help_texts = {
-            'actions': 'Actions granted in addition to those listed above'
+            'actions': 'Actions granted in addition to those listed above',
+            'attrs': 'JSON expression of a queryset filter that will return only permitted objects. Leave null to '
+                     'match all objects of this type.'
         }
         labels = {
             'actions': 'Additional actions'
@@ -106,6 +108,10 @@ class ObjectPermissionForm(forms.ModelForm):
         order_content_types(self.fields['content_types'])
         self.fields['content_types'].choices.insert(0, ('', '---------'))
 
+        # Order group and user fields
+        self.fields['groups'].queryset = self.fields['groups'].queryset.order_by('name')
+        self.fields['users'].queryset = self.fields['users'].queryset.order_by('username')
+
         # Check the appropriate checkboxes when editing an existing ObjectPermission
         if self.instance.pk:
             for action in ['view', 'add', 'change', 'delete']: