mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-31 04:46:26 -06:00
Remove redundant InterfaceVLANTranslationTable
This commit is contained in:
parent
e0f5fd048b
commit
79fbf64f86
@ -18,7 +18,7 @@ from jinja2.exceptions import TemplateError
|
|||||||
from circuits.models import Circuit, CircuitTermination
|
from circuits.models import Circuit, CircuitTermination
|
||||||
from extras.views import ObjectConfigContextView
|
from extras.views import ObjectConfigContextView
|
||||||
from ipam.models import ASN, IPAddress, VLANGroup
|
from ipam.models import ASN, IPAddress, VLANGroup
|
||||||
from ipam.tables import InterfaceVLANTable, InterfaceVLANTranslationTable
|
from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
|
||||||
from netbox.constants import DEFAULT_ACTION_PERMISSIONS
|
from netbox.constants import DEFAULT_ACTION_PERMISSIONS
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
from tenancy.views import ObjectContactsView
|
from tenancy.views import ObjectContactsView
|
||||||
@ -2579,8 +2579,7 @@ class InterfaceView(generic.ObjectView):
|
|||||||
data=vlans,
|
data=vlans,
|
||||||
orderable=False
|
orderable=False
|
||||||
)
|
)
|
||||||
vlan_translation_table = InterfaceVLANTranslationTable(
|
vlan_translation_table = VLANTranslationRuleTable(
|
||||||
interface=instance,
|
|
||||||
data=instance.vlan_translation_policy.rules.all() if instance.vlan_translation_policy else [],
|
data=instance.vlan_translation_policy.rules.all() if instance.vlan_translation_policy else [],
|
||||||
orderable=False
|
orderable=False
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,6 @@ __all__ = (
|
|||||||
'VLANVirtualMachinesTable',
|
'VLANVirtualMachinesTable',
|
||||||
'VLANTranslationPolicyTable',
|
'VLANTranslationPolicyTable',
|
||||||
'VLANTranslationRuleTable',
|
'VLANTranslationRuleTable',
|
||||||
'InterfaceVLANTranslationTable',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
AVAILABLE_LABEL = mark_safe('<span class="badge text-bg-success">Available</span>')
|
AVAILABLE_LABEL = mark_safe('<span class="badge text-bg-success">Available</span>')
|
||||||
@ -295,26 +294,3 @@ class VLANTranslationRuleTable(NetBoxTable):
|
|||||||
'pk', 'id', 'name', 'policy', 'local_vid', 'remote_vid', 'tags', 'created', 'last_updated',
|
'pk', 'id', 'name', 'policy', 'local_vid', 'remote_vid', 'tags', 'created', 'last_updated',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'id', 'local_vid', 'remote_vid', 'policy')
|
default_columns = ('pk', 'id', 'local_vid', 'remote_vid', 'policy')
|
||||||
|
|
||||||
|
|
||||||
class InterfaceVLANTranslationTable(NetBoxTable):
|
|
||||||
policy = tables.Column(
|
|
||||||
verbose_name=_('Policy'),
|
|
||||||
linkify=True
|
|
||||||
)
|
|
||||||
local_vid = tables.Column(
|
|
||||||
verbose_name=_('Local VID'),
|
|
||||||
linkify=True,
|
|
||||||
)
|
|
||||||
remote_vid = tables.Column(
|
|
||||||
verbose_name=_('Remote VID'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta(NetBoxTable.Meta):
|
|
||||||
model = VLANTranslationRule
|
|
||||||
fields = ('local_vid', 'remote_vid')
|
|
||||||
default_columns = ('pk', 'local_vid', 'remote_vid', 'policy')
|
|
||||||
|
|
||||||
def __init__(self, interface, *args, **kwargs):
|
|
||||||
self.interface = interface
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
@ -9,6 +9,7 @@ from circuits.models import Provider
|
|||||||
from dcim.filtersets import InterfaceFilterSet
|
from dcim.filtersets import InterfaceFilterSet
|
||||||
from dcim.forms import InterfaceFilterForm
|
from dcim.forms import InterfaceFilterForm
|
||||||
from dcim.models import Interface, Site
|
from dcim.models import Interface, Site
|
||||||
|
from ipam.tables import VLANTranslationRuleTable
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
from tenancy.views import ObjectContactsView
|
from tenancy.views import ObjectContactsView
|
||||||
from utilities.query import count_related
|
from utilities.query import count_related
|
||||||
@ -1002,8 +1003,12 @@ class VLANTranslationPolicyView(GetRelatedModelsMixin, generic.ObjectView):
|
|||||||
queryset = VLANTranslationPolicy.objects.all()
|
queryset = VLANTranslationPolicy.objects.all()
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
|
vlan_translation_table = VLANTranslationRuleTable(
|
||||||
|
data=instance.rules.all(),
|
||||||
|
orderable=False
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
'related_models': self.get_related_models(request, instance),
|
'vlan_translation_table': vlan_translation_table,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
{% plugin_right_page object %}
|
{% plugin_right_page object %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col col-md-12">
|
||||||
|
{% include 'inc/panel_table.html' with table=vlan_translation_table heading="VLAN Translation Rules" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
{% plugin_full_width_page object %}
|
{% plugin_full_width_page object %}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<table class="table table-hover attr-table">
|
<table class="table table-hover attr-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{% trans "Policy" %}</th>
|
<th scope="row">{% trans "Policy" %}</th>
|
||||||
<td>{{ object.policy|placeholder }}</td>
|
<td>{{ object.policy|linkify }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{% trans "Local VID" %}</th>
|
<th scope="row">{% trans "Local VID" %}</th>
|
||||||
|
@ -16,7 +16,7 @@ from dcim.models import Device
|
|||||||
from dcim.tables import DeviceTable
|
from dcim.tables import DeviceTable
|
||||||
from extras.views import ObjectConfigContextView
|
from extras.views import ObjectConfigContextView
|
||||||
from ipam.models import IPAddress
|
from ipam.models import IPAddress
|
||||||
from ipam.tables import InterfaceVLANTable, InterfaceVLANTranslationTable
|
from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
|
||||||
from netbox.constants import DEFAULT_ACTION_PERMISSIONS
|
from netbox.constants import DEFAULT_ACTION_PERMISSIONS
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
from tenancy.views import ObjectContactsView
|
from tenancy.views import ObjectContactsView
|
||||||
@ -515,8 +515,7 @@ class VMInterfaceView(generic.ObjectView):
|
|||||||
exclude=('virtual_machine',),
|
exclude=('virtual_machine',),
|
||||||
orderable=False
|
orderable=False
|
||||||
)
|
)
|
||||||
vlan_translation_table = InterfaceVLANTranslationTable(
|
vlan_translation_table = VLANTranslationRuleTable(
|
||||||
interface=instance,
|
|
||||||
data=instance.vlan_translation_policy.rules.all() if instance.vlan_translation_policy else [],
|
data=instance.vlan_translation_policy.rules.all() if instance.vlan_translation_policy else [],
|
||||||
orderable=False
|
orderable=False
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user