mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Represent and assign ConfigContext tags by their slugs
This commit is contained in:
parent
fd88ba65b2
commit
19363add30
@ -173,9 +173,9 @@ class ConfigContextSerializer(ValidatedModelSerializer):
|
||||
required=False,
|
||||
many=True
|
||||
)
|
||||
tags = SerializedPKRelatedField(
|
||||
tags = serializers.SlugRelatedField(
|
||||
queryset=Tag.objects.all(),
|
||||
serializer=TagSerializer,
|
||||
slug_field='slug',
|
||||
required=False,
|
||||
many=True
|
||||
)
|
||||
|
@ -370,8 +370,8 @@ class ConfigContextTest(APITestCase):
|
||||
tenantgroup2 = TenantGroup.objects.create(name='Test Tenant Group 2', slug='test-tenant-group-2')
|
||||
tenant1 = Tenant.objects.create(name='Test Tenant 1', slug='test-tenant-1')
|
||||
tenant2 = Tenant.objects.create(name='Test Tenant 2', slug='test-tenant-2')
|
||||
tag1 = Tag.objects.create(name='Test Tag 1', slug='test-ta-1')
|
||||
tag2 = Tag.objects.create(name='Test Tag 2', slug='test-ta-2')
|
||||
tag1 = Tag.objects.create(name='Test Tag 1', slug='test-tag-1')
|
||||
tag2 = Tag.objects.create(name='Test Tag 2', slug='test-tag-2')
|
||||
|
||||
data = {
|
||||
'name': 'Test Config Context 4',
|
||||
@ -382,7 +382,7 @@ class ConfigContextTest(APITestCase):
|
||||
'platforms': [platform1.pk, platform2.pk],
|
||||
'tenant_groups': [tenantgroup1.pk, tenantgroup2.pk],
|
||||
'tenants': [tenant1.pk, tenant2.pk],
|
||||
'tags': [tag1.pk, tag2.pk],
|
||||
'tags': [tag1.slug, tag2.slug],
|
||||
'data': {'foo': 'XXX'}
|
||||
}
|
||||
|
||||
@ -405,8 +405,8 @@ class ConfigContextTest(APITestCase):
|
||||
self.assertEqual(tenantgroup2.pk, data['tenant_groups'][1])
|
||||
self.assertEqual(tenant1.pk, data['tenants'][0])
|
||||
self.assertEqual(tenant2.pk, data['tenants'][1])
|
||||
self.assertEqual(tag1.pk, data['tags'][0])
|
||||
self.assertEqual(tag2.pk, data['tags'][1])
|
||||
self.assertEqual(tag1.slug, data['tags'][0])
|
||||
self.assertEqual(tag2.slug, data['tags'][1])
|
||||
self.assertEqual(configcontext4.data, data['data'])
|
||||
|
||||
def test_create_configcontext_bulk(self):
|
||||
|
Loading…
Reference in New Issue
Block a user