mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-31 04:46:26 -06:00
Add description field to VLANTranslationRule
This commit is contained in:
parent
d9dde5c4f4
commit
722c7ba6af
@ -1130,7 +1130,7 @@ class VLANTranslationRuleFilterSet(NetBoxModelFilterSet):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANTranslationRule
|
model = VLANTranslationRule
|
||||||
fields = ('id', 'policy_id', 'local_vid', 'remote_vid')
|
fields = ('id', 'policy_id', 'local_vid', 'remote_vid', 'description')
|
||||||
|
|
||||||
def search(self, queryset, name, value):
|
def search(self, queryset, name, value):
|
||||||
if not value.strip():
|
if not value.strip():
|
||||||
|
@ -467,16 +467,12 @@ class VLANTranslationPolicyFilterForm(NetBoxModelFilterSetForm):
|
|||||||
model = VLANTranslationPolicy
|
model = VLANTranslationPolicy
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag'),
|
FieldSet('q', 'filter_id', 'tag'),
|
||||||
FieldSet('name', 'description', name=_('Attributes')),
|
FieldSet('name', name=_('Attributes')),
|
||||||
)
|
)
|
||||||
name = forms.CharField(
|
name = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label=_('Name')
|
label=_('Name')
|
||||||
)
|
)
|
||||||
description = forms.CharField(
|
|
||||||
required=False,
|
|
||||||
label=_('Name')
|
|
||||||
)
|
|
||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
|
@ -714,13 +714,13 @@ class VLANTranslationRuleForm(NetBoxModelForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('policy', 'local_vid', 'remote_vid', 'tags', name=_('VLAN Translation Rule')),
|
FieldSet('policy', 'local_vid', 'remote_vid', 'description', 'tags', name=_('VLAN Translation Rule')),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANTranslationRule
|
model = VLANTranslationRule
|
||||||
fields = [
|
fields = [
|
||||||
'policy', 'local_vid', 'remote_vid', 'tags',
|
'policy', 'local_vid', 'remote_vid', 'description', 'tags',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class Migration(migrations.Migration):
|
|||||||
('local_vid', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4094)])),
|
('local_vid', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4094)])),
|
||||||
('remote_vid', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4094)])),
|
('remote_vid', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4094)])),
|
||||||
('policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rules', to='ipam.vlantranslationpolicy')),
|
('policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rules', to='ipam.vlantranslationpolicy')),
|
||||||
|
('description', models.CharField(blank=True, max_length=200)),
|
||||||
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
@ -299,6 +299,11 @@ class VLANTranslationRule(NetBoxModel):
|
|||||||
related_name='rules',
|
related_name='rules',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
)
|
)
|
||||||
|
description = models.CharField(
|
||||||
|
verbose_name=_('description'),
|
||||||
|
max_length=200,
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
local_vid = models.PositiveSmallIntegerField(
|
local_vid = models.PositiveSmallIntegerField(
|
||||||
verbose_name=_('Local VLAN ID'),
|
verbose_name=_('Local VLAN ID'),
|
||||||
validators=(
|
validators=(
|
||||||
|
@ -1086,16 +1086,19 @@ class VLANTranslationRuleTest(APIViewTestCases.APIViewTestCase):
|
|||||||
policy=vlan_translation_policies[0],
|
policy=vlan_translation_policies[0],
|
||||||
local_vid=100,
|
local_vid=100,
|
||||||
remote_vid=200,
|
remote_vid=200,
|
||||||
|
description='foo',
|
||||||
),
|
),
|
||||||
VLANTranslationRule(
|
VLANTranslationRule(
|
||||||
policy=vlan_translation_policies[0],
|
policy=vlan_translation_policies[0],
|
||||||
local_vid=101,
|
local_vid=101,
|
||||||
remote_vid=201,
|
remote_vid=201,
|
||||||
|
description='bar',
|
||||||
),
|
),
|
||||||
VLANTranslationRule(
|
VLANTranslationRule(
|
||||||
policy=vlan_translation_policies[1],
|
policy=vlan_translation_policies[1],
|
||||||
local_vid=102,
|
local_vid=102,
|
||||||
remote_vid=202,
|
remote_vid=202,
|
||||||
|
description='baz',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
VLANTranslationRule.objects.bulk_create(vlan_translation_rules)
|
VLANTranslationRule.objects.bulk_create(vlan_translation_rules)
|
||||||
|
@ -1954,16 +1954,19 @@ class VLANTranslationRuleTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
policy=vlan_translation_policies[0],
|
policy=vlan_translation_policies[0],
|
||||||
local_vid=100,
|
local_vid=100,
|
||||||
remote_vid=200,
|
remote_vid=200,
|
||||||
|
description='foo',
|
||||||
),
|
),
|
||||||
VLANTranslationRule(
|
VLANTranslationRule(
|
||||||
policy=vlan_translation_policies[0],
|
policy=vlan_translation_policies[0],
|
||||||
local_vid=101,
|
local_vid=101,
|
||||||
remote_vid=201,
|
remote_vid=201,
|
||||||
|
description='bar',
|
||||||
),
|
),
|
||||||
VLANTranslationRule(
|
VLANTranslationRule(
|
||||||
policy=vlan_translation_policies[1],
|
policy=vlan_translation_policies[1],
|
||||||
local_vid=100,
|
local_vid=100,
|
||||||
remote_vid=200,
|
remote_vid=200,
|
||||||
|
description='baz',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
VLANTranslationRule.objects.bulk_create(vlan_translation_rules)
|
VLANTranslationRule.objects.bulk_create(vlan_translation_rules)
|
||||||
@ -1981,6 +1984,10 @@ class VLANTranslationRuleTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
params = {'remote_vid': [200]}
|
params = {'remote_vid': [200]}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
|
|
||||||
|
def test_description(self):
|
||||||
|
params = {'description': ['foo', 'bar']}
|
||||||
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
|
|
||||||
|
|
||||||
class ServiceTemplateTestCase(TestCase, ChangeLoggedFilterSetTests):
|
class ServiceTemplateTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||||
queryset = ServiceTemplate.objects.all()
|
queryset = ServiceTemplate.objects.all()
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
<th scope="row">{% trans "Remote VID" %}</th>
|
<th scope="row">{% trans "Remote VID" %}</th>
|
||||||
<td>{{ object.remote_vid }}</td>
|
<td>{{ object.remote_vid }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Description" %}</th>
|
||||||
|
<td>{{ object.description }}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% plugin_left_page object %}
|
{% plugin_left_page object %}
|
||||||
|
Loading…
Reference in New Issue
Block a user