Relocate CSS classes for ChoiceFields from model to ChoiceSet

This commit is contained in:
Jeremy Stretch
2020-09-24 16:35:53 -04:00
parent bddd010310
commit 1b55285167
13 changed files with 114 additions and 114 deletions

View File

@@ -600,16 +600,6 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
'device_type', 'device_role', 'tenant', 'platform', 'site', 'rack', 'status', 'cluster',
]
STATUS_CLASS_MAP = {
DeviceStatusChoices.STATUS_OFFLINE: 'warning',
DeviceStatusChoices.STATUS_ACTIVE: 'success',
DeviceStatusChoices.STATUS_PLANNED: 'info',
DeviceStatusChoices.STATUS_STAGED: 'primary',
DeviceStatusChoices.STATUS_FAILED: 'danger',
DeviceStatusChoices.STATUS_INVENTORY: 'default',
DeviceStatusChoices.STATUS_DECOMMISSIONING: 'warning',
}
class Meta:
ordering = ('_name', 'pk') # Name may be null
unique_together = (
@@ -881,7 +871,7 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
return Device.objects.filter(parent_bay__device=self.pk)
def get_status_class(self):
return self.STATUS_CLASS_MAP.get(self.status)
return DeviceStatusChoices.CSS_CLASSES.get(self.status)
#
@@ -973,12 +963,6 @@ class Cable(ChangeLoggedModel, CustomFieldModel):
'color', 'length', 'length_unit',
]
STATUS_CLASS_MAP = {
CableStatusChoices.STATUS_CONNECTED: 'success',
CableStatusChoices.STATUS_PLANNED: 'info',
CableStatusChoices.STATUS_DECOMMISSIONING: 'warning',
}
class Meta:
ordering = ['pk']
unique_together = (
@@ -1159,7 +1143,7 @@ class Cable(ChangeLoggedModel, CustomFieldModel):
)
def get_status_class(self):
return self.STATUS_CLASS_MAP.get(self.status)
return CableStatusChoices.CSS_CLASSES.get(self.status)
def get_compatible_types(self):
"""