mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 17:59:11 -06:00
#7336: Misc cleanup
This commit is contained in:
parent
5afa6d7964
commit
6d65d92c38
@ -121,7 +121,7 @@ class VLANTranslationRuleSerializer(NetBoxModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANTranslationRule
|
model = VLANTranslationRule
|
||||||
fields = ['id', 'policy', 'local_vid', 'remote_vid']
|
fields = ['id', 'url', 'display', 'policy', 'local_vid', 'remote_vid', 'description']
|
||||||
|
|
||||||
|
|
||||||
class VLANTranslationPolicySerializer(NetBoxModelSerializer):
|
class VLANTranslationPolicySerializer(NetBoxModelSerializer):
|
||||||
@ -129,5 +129,5 @@ class VLANTranslationPolicySerializer(NetBoxModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANTranslationPolicy
|
model = VLANTranslationPolicy
|
||||||
fields = ['id', 'url', 'name', 'description', 'display', 'rules']
|
fields = ['id', 'url', 'display', 'name', 'description', 'display', 'rules']
|
||||||
brief_fields = ('id', 'url', 'name', 'description', 'display')
|
brief_fields = ('id', 'url', 'display', 'name', 'description')
|
||||||
|
@ -487,6 +487,12 @@ class VLANTranslationPolicyImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class VLANTranslationRuleImportForm(NetBoxModelImportForm):
|
class VLANTranslationRuleImportForm(NetBoxModelImportForm):
|
||||||
|
policy = CSVModelChoiceField(
|
||||||
|
label=_('Policy'),
|
||||||
|
queryset=VLANTranslationPolicy.objects.all(),
|
||||||
|
to_field_name='name',
|
||||||
|
help_text=_('VLAN translation policy')
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANTranslationRule
|
model = VLANTranslationRule
|
||||||
|
@ -379,6 +379,8 @@ class VLANTranslationRule(NetBoxModel):
|
|||||||
'ipam.VLANTranslationPolicy',
|
'ipam.VLANTranslationPolicy',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
clone_fields = ['policy']
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('VLAN translation rule')
|
verbose_name = _('VLAN translation rule')
|
||||||
ordering = ('policy', 'local_vid',)
|
ordering = ('policy', 'local_vid',)
|
||||||
|
@ -231,6 +231,11 @@ class VLANTranslationPolicyTable(NetBoxTable):
|
|||||||
verbose_name=_('Name'),
|
verbose_name=_('Name'),
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
|
rule_count = columns.LinkedCountColumn(
|
||||||
|
viewname='ipam:vlantranslationrule_list',
|
||||||
|
url_params={'policy_id': 'pk'},
|
||||||
|
verbose_name=_('Rules')
|
||||||
|
)
|
||||||
description = tables.Column(
|
description = tables.Column(
|
||||||
verbose_name=_('Description'),
|
verbose_name=_('Description'),
|
||||||
)
|
)
|
||||||
@ -241,9 +246,9 @@ class VLANTranslationPolicyTable(NetBoxTable):
|
|||||||
class Meta(NetBoxTable.Meta):
|
class Meta(NetBoxTable.Meta):
|
||||||
model = VLANTranslationPolicy
|
model = VLANTranslationPolicy
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'description', 'tags', 'created', 'last_updated',
|
'pk', 'id', 'name', 'rule_count', 'description', 'tags', 'created', 'last_updated',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'description')
|
default_columns = ('pk', 'name', 'rule_count', 'description')
|
||||||
|
|
||||||
|
|
||||||
class VLANTranslationRuleTable(NetBoxTable):
|
class VLANTranslationRuleTable(NetBoxTable):
|
||||||
|
@ -973,16 +973,16 @@ class VLANTranslationRuleTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
"policy,local_vid,remote_vid",
|
"policy,local_vid,remote_vid",
|
||||||
f"{vlan_translation_policies[0].pk},103,203",
|
f"{vlan_translation_policies[0].name},103,203",
|
||||||
f"{vlan_translation_policies[0].pk},104,204",
|
f"{vlan_translation_policies[0].name},104,204",
|
||||||
f"{vlan_translation_policies[1].pk},105,205",
|
f"{vlan_translation_policies[1].name},105,205",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.csv_update_data = (
|
cls.csv_update_data = (
|
||||||
"id,policy,local_vid,remote_vid",
|
"id,local_vid,remote_vid",
|
||||||
f"{vlan_translation_rules[0].pk},{vlan_translation_policies[1].pk},105,205",
|
f"{vlan_translation_rules[0].pk},105,205",
|
||||||
f"{vlan_translation_rules[1].pk},{vlan_translation_policies[1].pk},106,206",
|
f"{vlan_translation_rules[1].pk},106,206",
|
||||||
f"{vlan_translation_rules[2].pk},{vlan_translation_policies[0].pk},107,207",
|
f"{vlan_translation_rules[2].pk},107,207",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
|
@ -1050,7 +1050,9 @@ class VLANGroupVLANsView(generic.ObjectChildrenView):
|
|||||||
|
|
||||||
@register_model_view(VLANTranslationPolicy, 'list', path='', detail=False)
|
@register_model_view(VLANTranslationPolicy, 'list', path='', detail=False)
|
||||||
class VLANTranslationPolicyListView(generic.ObjectListView):
|
class VLANTranslationPolicyListView(generic.ObjectListView):
|
||||||
queryset = VLANTranslationPolicy.objects.all()
|
queryset = VLANTranslationPolicy.objects.annotate(
|
||||||
|
rule_count=count_related(VLANTranslationRule, 'policy'),
|
||||||
|
)
|
||||||
filterset = filtersets.VLANTranslationPolicyFilterSet
|
filterset = filtersets.VLANTranslationPolicyFilterSet
|
||||||
filterset_form = forms.VLANTranslationPolicyFilterForm
|
filterset_form = forms.VLANTranslationPolicyFilterForm
|
||||||
table = tables.VLANTranslationPolicyTable
|
table = tables.VLANTranslationPolicyTable
|
||||||
|
@ -18,6 +18,16 @@
|
|||||||
<th scope="row">{% trans "Description" %}</th>
|
<th scope="row">{% trans "Description" %}</th>
|
||||||
<td>{{ object.description|placeholder }}</td>
|
<td>{{ object.description|placeholder }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Rules" %}</th>
|
||||||
|
<td>
|
||||||
|
{% if object.rules.count %}
|
||||||
|
<a href="{% url 'ipam:vlantranslationrule_list' %}?policy_id={{ object.pk }}">{{ object.rules.count }}</a>
|
||||||
|
{% else %}
|
||||||
|
0
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% plugin_left_page object %}
|
{% plugin_left_page object %}
|
||||||
|
Loading…
Reference in New Issue
Block a user