Procházet zdrojové kódy

Adds PowerOutlet.status to detail view

Also fixes color display in list table and detail template
Jason Novinger před 11 měsíci
rodič
revize
913405a3ae

+ 3 - 0
netbox/dcim/models/device_components.py

@@ -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

+ 3 - 0
netbox/dcim/tables/devices.py

@@ -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'

+ 4 - 0
netbox/templates/dcim/poweroutlet.html

@@ -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>