mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
using cable.get_trace_url
This commit is contained in:
parent
cf2f39a0a8
commit
aef9a6ca53
@ -231,6 +231,12 @@ class Cable(PrimaryModel):
|
|||||||
def get_status_color(self):
|
def get_status_color(self):
|
||||||
return LinkStatusChoices.colors.get(self.status)
|
return LinkStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
|
def get_trace_url(self):
|
||||||
|
for cabletermination in self.terminations.all():
|
||||||
|
if cabletermination.termination_type.model in ['interface', 'rearport', 'frontport', 'consoleport', 'consoleserverport', 'powerport', 'poweroutlet']:
|
||||||
|
return reverse(f'dcim:{cabletermination.termination_type.model}_trace', kwargs={'pk': cabletermination.termination.pk})
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class CableTermination(ChangeLoggedModel):
|
class CableTermination(ChangeLoggedModel):
|
||||||
"""
|
"""
|
||||||
|
@ -116,6 +116,9 @@ class CableTable(TenancyColumnsMixin, NetBoxTable):
|
|||||||
tags = columns.TagColumn(
|
tags = columns.TagColumn(
|
||||||
url_name='dcim:cable_list'
|
url_name='dcim:cable_list'
|
||||||
)
|
)
|
||||||
|
actions = columns.ActionsColumn(
|
||||||
|
extra_buttons='{% if record.get_trace_url %}<a href="{{ record.get_trace_url }}" class="btn btn-sm btn-primary" title="Trace"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>{% endif %}'
|
||||||
|
)
|
||||||
|
|
||||||
class Meta(NetBoxTable.Meta):
|
class Meta(NetBoxTable.Meta):
|
||||||
model = Cable
|
model = Cable
|
||||||
|
@ -20,6 +20,14 @@
|
|||||||
<th scope="row">{% trans "Status" %}</th>
|
<th scope="row">{% trans "Status" %}</th>
|
||||||
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if object.get_trace_url %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Trace</th>
|
||||||
|
<td>
|
||||||
|
<a href="{{ object.get_trace_url }}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{% trans "Tenant" %}</th>
|
<th scope="row">{% trans "Tenant" %}</th>
|
||||||
<td>
|
<td>
|
||||||
|
Loading…
Reference in New Issue
Block a user