mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-24 12:32:42 -06:00
Made DeviceRoles hierarchical, had to also change the filtersets for Device, ConfigContext and VirtualMachine to use the TreeNodeMultipleChoiceFilter. Note: The model was changed to use NestedGroupModel, a side-effect of this is it also adds comments field, but I thought that was better then doing a one-off just for DeviceRole and having to define the fields, validators, etc.. - keeps everything DRY / consistent. * 18981 Make Device Roles Hierarchical * 18981 forms, serializer * 18981 fix tests * 18981 fix tests * 18981 fix tests * 18981 fix tests * 18981 fix tests * 18981 fix migration merge * 18981 fix tests * 18981 fix filtersets * 18981 fix tests * 18981 comments * 18981 review changes
This commit is contained in:
@@ -171,13 +171,15 @@ class VirtualMachineFilterSet(
|
||||
name = MultiValueCharFilter(
|
||||
lookup_expr='iexact'
|
||||
)
|
||||
role_id = django_filters.ModelMultipleChoiceFilter(
|
||||
role_id = TreeNodeMultipleChoiceFilter(
|
||||
queryset=DeviceRole.objects.all(),
|
||||
lookup_expr='in',
|
||||
label=_('Role (ID)'),
|
||||
)
|
||||
role = django_filters.ModelMultipleChoiceFilter(
|
||||
field_name='role__slug',
|
||||
role = TreeNodeMultipleChoiceFilter(
|
||||
field_name='role',
|
||||
queryset=DeviceRole.objects.all(),
|
||||
lookup_expr='in',
|
||||
to_field_name='slug',
|
||||
label=_('Role (slug)'),
|
||||
)
|
||||
|
||||
@@ -294,7 +294,8 @@ class VirtualMachineTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
DeviceRole(name='Device Role 2', slug='device-role-2'),
|
||||
DeviceRole(name='Device Role 3', slug='device-role-3'),
|
||||
)
|
||||
DeviceRole.objects.bulk_create(roles)
|
||||
for role in roles:
|
||||
role.save()
|
||||
|
||||
devices = (
|
||||
create_test_device('device1', cluster=clusters[0]),
|
||||
|
||||
@@ -203,7 +203,8 @@ class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
DeviceRole(name='Device Role 1', slug='device-role-1'),
|
||||
DeviceRole(name='Device Role 2', slug='device-role-2'),
|
||||
)
|
||||
DeviceRole.objects.bulk_create(roles)
|
||||
for role in roles:
|
||||
role.save()
|
||||
|
||||
platforms = (
|
||||
Platform(name='Platform 1', slug='platform-1'),
|
||||
|
||||
Reference in New Issue
Block a user