mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-31 04:46:26 -06:00
Explicitly prefetch policy in graphql
This commit is contained in:
parent
24caa3bf1f
commit
ae93ce848b
@ -291,7 +291,7 @@ class VLANTranslationPolicyType(NetBoxObjectType):
|
|||||||
filters=VLANTranslationRuleFilter
|
filters=VLANTranslationRuleFilter
|
||||||
)
|
)
|
||||||
class VLANTranslationRuleType(NetBoxObjectType):
|
class VLANTranslationRuleType(NetBoxObjectType):
|
||||||
policy: Annotated["VLANTranslationPolicyType", strawberry.lazy('ipam.graphql.types')] | None
|
policy: Annotated["VLANTranslationPolicyType", strawberry.lazy('ipam.graphql.types')] = strawberry_django.field(select_related=["policy"])
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
|
@ -315,6 +315,9 @@ class VLANTranslationRule(NetBoxModel):
|
|||||||
),
|
),
|
||||||
help_text=_("Numeric VLAN ID (1-4094)")
|
help_text=_("Numeric VLAN ID (1-4094)")
|
||||||
)
|
)
|
||||||
|
prerequisite_models = (
|
||||||
|
'ipam.VLANTranslationPolicy',
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('VLAN translation rule')
|
verbose_name = _('VLAN translation rule')
|
||||||
@ -331,8 +334,7 @@ class VLANTranslationRule(NetBoxModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.local_vid} -> {self.remote_vid}'
|
return f'{self.local_vid} -> {self.remote_vid} ({self.policy})'
|
||||||
# return f'{self.local_vid} -> {self.remote_vid} ({self.policy})'
|
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
|
@ -1065,10 +1065,6 @@ class VLANTranslationPolicyTest(APIViewTestCases.APIViewTestCase):
|
|||||||
class VLANTranslationRuleTest(APIViewTestCases.APIViewTestCase):
|
class VLANTranslationRuleTest(APIViewTestCases.APIViewTestCase):
|
||||||
model = VLANTranslationRule
|
model = VLANTranslationRule
|
||||||
brief_fields = ['id', 'local_vid', 'policy', 'remote_vid',]
|
brief_fields = ['id', 'local_vid', 'policy', 'remote_vid',]
|
||||||
bulk_update_data = {
|
|
||||||
'policy': '109',
|
|
||||||
'remote_vid': '209',
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1103,7 +1099,6 @@ class VLANTranslationRuleTest(APIViewTestCases.APIViewTestCase):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
VLANTranslationRule.objects.bulk_create(vlan_translation_rules)
|
VLANTranslationRule.objects.bulk_create(vlan_translation_rules)
|
||||||
print(VLANTranslationRule.objects.all().values('id', 'policy'))
|
|
||||||
|
|
||||||
cls.create_data = [
|
cls.create_data = [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user