Adds PowerOutlet.status to detail view

Also fixes color display in list table and detail template
This commit is contained in:
Jason Novinger 2025-03-03 12:22:34 -06:00
parent 2ae84ce9fb
commit 913405a3ae
3 changed files with 10 additions and 0 deletions

View File

@ -498,6 +498,9 @@ class PowerOutlet(ModularComponentModel, CabledObjectModel, PathEndpoint, Tracki
_("Parent power port ({power_port}) must belong to the same device").format(power_port=self.power_port) _("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 # Interfaces

View File

@ -520,6 +520,9 @@ class PowerOutletTable(ModularDeviceComponentTable, PathEndpointTable):
verbose_name=_('Power Port'), verbose_name=_('Power Port'),
linkify=True linkify=True
) )
status = columns.ChoiceFieldColumn(
verbose_name=_('Status'),
)
color = columns.ColorColumn() color = columns.ColorColumn()
tags = columns.TagColumn( tags = columns.TagColumn(
url_name='dcim:poweroutlet_list' url_name='dcim:poweroutlet_list'

View File

@ -36,6 +36,10 @@
<th scope="row">{% trans "Type" %}</th> <th scope="row">{% trans "Type" %}</th>
<td>{{ object.get_type_display }}</td> <td>{{ object.get_type_display }}</td>
</tr> </tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
</tr>
<tr> <tr>
<th scope="row">{% trans "Description" %}</th> <th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td> <td>{{ object.description|placeholder }}</td>