Closes #19740: Enable recursive nesting for platforms

This commit is contained in:
Jeremy Stretch
2025-08-07 15:52:27 -04:00
parent 33d891e67b
commit 148fac1086
22 changed files with 286 additions and 41 deletions

View File

@@ -183,13 +183,16 @@ class VirtualMachineFilterSet(
to_field_name='slug',
label=_('Role (slug)'),
)
platform_id = django_filters.ModelMultipleChoiceFilter(
platform_id = TreeNodeMultipleChoiceFilter(
queryset=Platform.objects.all(),
field_name='platform',
lookup_expr='in',
label=_('Platform (ID)'),
)
platform = django_filters.ModelMultipleChoiceFilter(
field_name='platform__slug',
platform = TreeNodeMultipleChoiceFilter(
queryset=Platform.objects.all(),
field_name='platform',
lookup_expr='in',
to_field_name='slug',
label=_('Platform (slug)'),
)

View File

@@ -287,7 +287,8 @@ class VirtualMachineTestCase(TestCase, ChangeLoggedFilterSetTests):
Platform(name='Platform 2', slug='platform-2'),
Platform(name='Platform 3', slug='platform-3'),
)
Platform.objects.bulk_create(platforms)
for platform in platforms:
platform.save()
roles = (
DeviceRole(name='Device Role 1', slug='device-role-1'),

View File

@@ -210,7 +210,8 @@ class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
Platform(name='Platform 1', slug='platform-1'),
Platform(name='Platform 2', slug='platform-2'),
)
Platform.objects.bulk_create(platforms)
for platform in platforms:
platform.save()
sites = (
Site(name='Site 1', slug='site-1'),