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:
@ -90,7 +90,9 @@ class ObjectPermissionForm(forms.ModelForm):
|
|||||||
model = ObjectPermission
|
model = ObjectPermission
|
||||||
exclude = []
|
exclude = []
|
||||||
help_texts = {
|
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 = {
|
labels = {
|
||||||
'actions': 'Additional actions'
|
'actions': 'Additional actions'
|
||||||
@ -106,6 +108,10 @@ class ObjectPermissionForm(forms.ModelForm):
|
|||||||
order_content_types(self.fields['content_types'])
|
order_content_types(self.fields['content_types'])
|
||||||
self.fields['content_types'].choices.insert(0, ('', '---------'))
|
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
|
# Check the appropriate checkboxes when editing an existing ObjectPermission
|
||||||
if self.instance.pk:
|
if self.instance.pk:
|
||||||
for action in ['view', 'add', 'change', 'delete']:
|
for action in ['view', 'add', 'change', 'delete']:
|
||||||
|
Reference in New Issue
Block a user