Also fixes color display in list table and detail template
@@ -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)
)
+ def get_status_color(self):
+ return PowerOutletStatusChoices.colors.get(self.status)
+
#
# Interfaces
@@ -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'
@@ -36,6 +36,10 @@
<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>