Skip to content

Commit

Permalink
Adds PowerOutlet.status to detail view
Browse files Browse the repository at this point in the history
Also fixes color display in list table and detail template
  • Loading branch information
jnovinger committed Mar 3, 2025
1 parent 2ae84ce commit 913405a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions netbox/dcim/models/device_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ def clean(self):
_("Parent power port ({power_port}) must belong to the same device").format(power_port=self.power_port)
)

def get_status_color(self):
return PowerOutletStatusChoices.colors.get(self.status)


#
# Interfaces
Expand Down
3 changes: 3 additions & 0 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ class PowerOutletTable(ModularDeviceComponentTable, PathEndpointTable):
verbose_name=_('Power Port'),
linkify=True
)
status = columns.ChoiceFieldColumn(
verbose_name=_('Status'),
)
color = columns.ColorColumn()
tags = columns.TagColumn(
url_name='dcim:poweroutlet_list'
Expand Down
4 changes: 4 additions & 0 deletions netbox/templates/dcim/poweroutlet.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ <h2 class="card-header">{% trans "Power Outlet" %}</h2>
<th scope="row">{% trans "Type" %}</th>
<td>{{ object.get_type_display }}</td>
</tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
Expand Down

0 comments on commit 913405a

Please sign in to comment.