mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-30 04:16:24 -06:00
Add policy (name) filter to VLANTranslationRuleFilterSet
This commit is contained in:
parent
04fb92fa98
commit
94d7015c5e
@ -1127,10 +1127,16 @@ class VLANTranslationRuleFilterSet(NetBoxModelFilterSet):
|
||||
queryset=VLANTranslationPolicy.objects.all(),
|
||||
label=_('VLAN Translation Policy (ID)'),
|
||||
)
|
||||
policy = django_filters.ModelMultipleChoiceFilter(
|
||||
field_name='policy__name',
|
||||
queryset=VLANTranslationPolicy.objects.all(),
|
||||
to_field_name='name',
|
||||
label=_('VLAN Translation Policy (name)'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = VLANTranslationRule
|
||||
fields = ('id', 'policy_id', 'local_vid', 'remote_vid', 'description')
|
||||
fields = ('id', 'policy_id', 'policy', 'local_vid', 'remote_vid', 'description')
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
|
@ -1976,6 +1976,11 @@ class VLANTranslationRuleTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
params = {'policy_id': [policies[0].pk]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_policy(self):
|
||||
policies = VLANTranslationPolicy.objects.all()[:2]
|
||||
params = {'policy': [policies[0].name]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_local_vid(self):
|
||||
params = {'local_vid': [100]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
Loading…
Reference in New Issue
Block a user