mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
using cable.get_trace_url
This commit is contained in:
parent
561f1eadfc
commit
4fe5a46364
@ -219,6 +219,12 @@ class Cable(PrimaryModel):
|
||||
def get_status_color(self):
|
||||
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(models.Model):
|
||||
"""
|
||||
|
@ -115,6 +115,9 @@ class CableTable(TenancyColumnsMixin, NetBoxTable):
|
||||
tags = columns.TagColumn(
|
||||
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):
|
||||
model = Cable
|
||||
|
@ -19,6 +19,14 @@
|
||||
<th scope="row">Status</th>
|
||||
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||
</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>
|
||||
<th scope="row">Tenant</th>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user