From 5d4cc5bf3d278cb124a5cb05d3b302d87a0c9c4b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 1 Jun 2020 13:59:58 -0400 Subject: [PATCH] Fix ordering of group and user fields in ObjectPermission admin --- netbox/users/admin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/netbox/users/admin.py b/netbox/users/admin.py index c1b659a8e..4c3da5acd 100644 --- a/netbox/users/admin.py +++ b/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']: