mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Closes #4943: Add a 'description' field to ObjectPermission
This commit is contained in:
parent
ce2dada9fd
commit
053c600b67
@ -22,6 +22,7 @@
|
||||
|
||||
* [#4940](https://github.com/netbox-community/netbox/issues/4940) - Add an `occupied` field to rack unit representations for rack elevation views
|
||||
* [#4942](https://github.com/netbox-community/netbox/issues/4942) - Make ObjectPermission's `name` field required
|
||||
* [#4943](https://github.com/netbox-community/netbox/issues/4943) - Add a `description` field to ObjectPermission
|
||||
|
||||
---
|
||||
|
||||
|
@ -232,7 +232,7 @@ class ObjectPermissionAdmin(admin.ModelAdmin):
|
||||
actions = ('enable', 'disable')
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'fields': ('name', 'enabled')
|
||||
'fields': ('name', 'description', 'enabled')
|
||||
}),
|
||||
('Actions', {
|
||||
'fields': (('can_view', 'can_add', 'can_change', 'can_delete'), 'actions')
|
||||
@ -251,11 +251,12 @@ class ObjectPermissionAdmin(admin.ModelAdmin):
|
||||
filter_horizontal = ('object_types', 'groups', 'users')
|
||||
form = ObjectPermissionForm
|
||||
list_display = [
|
||||
'name', 'enabled', 'list_models', 'list_users', 'list_groups', 'actions', 'constraints',
|
||||
'name', 'enabled', 'list_models', 'list_users', 'list_groups', 'actions', 'constraints', 'description',
|
||||
]
|
||||
list_filter = [
|
||||
'enabled', ActionListFilter, ObjectTypeListFilter, 'groups', 'users'
|
||||
]
|
||||
search_fields = ['actions', 'constraints', 'description', 'name']
|
||||
|
||||
def get_queryset(self, request):
|
||||
return super().get_queryset(request).prefetch_related('object_types', 'users', 'groups')
|
||||
|
@ -54,4 +54,6 @@ class ObjectPermissionSerializer(ValidatedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = ObjectPermission
|
||||
fields = ('id', 'url', 'name', 'enabled', 'object_types', 'groups', 'users', 'actions', 'constraints')
|
||||
fields = (
|
||||
'id', 'url', 'name', 'description', 'enabled', 'object_types', 'groups', 'users', 'actions', 'constraints',
|
||||
)
|
||||
|
@ -19,6 +19,7 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('description', models.CharField(blank=True, max_length=200)),
|
||||
('enabled', models.BooleanField(default=True)),
|
||||
('constraints', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True)),
|
||||
('actions', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=30), size=None)),
|
||||
|
@ -241,6 +241,10 @@ class ObjectPermission(models.Model):
|
||||
name = models.CharField(
|
||||
max_length=100
|
||||
)
|
||||
description = models.CharField(
|
||||
max_length=200,
|
||||
blank=True
|
||||
)
|
||||
enabled = models.BooleanField(
|
||||
default=True
|
||||
)
|
||||
|
@ -97,6 +97,7 @@ class ObjectPermissionTest(APIViewTestCases.APIViewTestCase):
|
||||
|
||||
for i in range(0, 3):
|
||||
objectpermission = ObjectPermission(
|
||||
name=f'Permission {i+1}',
|
||||
actions=['view', 'add', 'change', 'delete'],
|
||||
constraints={'name': f'TEST{i+1}'}
|
||||
)
|
||||
@ -107,6 +108,7 @@ class ObjectPermissionTest(APIViewTestCases.APIViewTestCase):
|
||||
|
||||
cls.create_data = [
|
||||
{
|
||||
'name': 'Permission 4',
|
||||
'object_types': ['dcim.site'],
|
||||
'groups': [groups[0].pk],
|
||||
'users': [users[0].pk],
|
||||
@ -114,6 +116,7 @@ class ObjectPermissionTest(APIViewTestCases.APIViewTestCase):
|
||||
'constraints': {'name': 'TEST4'},
|
||||
},
|
||||
{
|
||||
'name': 'Permission 5',
|
||||
'object_types': ['dcim.site'],
|
||||
'groups': [groups[1].pk],
|
||||
'users': [users[1].pk],
|
||||
@ -121,6 +124,7 @@ class ObjectPermissionTest(APIViewTestCases.APIViewTestCase):
|
||||
'constraints': {'name': 'TEST5'},
|
||||
},
|
||||
{
|
||||
'name': 'Permission 6',
|
||||
'object_types': ['dcim.site'],
|
||||
'groups': [groups[2].pk],
|
||||
'users': [users[2].pk],
|
||||
|
Loading…
Reference in New Issue
Block a user