1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix ordering of group and user fields in ObjectPermission admin

This commit is contained in:
Jeremy Stretch
2020-06-01 13:59:58 -04:00
parent 26d7c21314
commit 5d4cc5bf3d

View File

@ -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']: