1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Rack.status to slug (#3569)

This commit is contained in:
Jeremy Stretch
2019-11-15 22:03:41 -05:00
parent e1e09bff9b
commit c79c29e769
7 changed files with 69 additions and 25 deletions

View File

@@ -473,9 +473,10 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
blank=True,
null=True
)
status = models.PositiveSmallIntegerField(
choices=RACK_STATUS_CHOICES,
default=RACK_STATUS_ACTIVE
status = models.CharField(
max_length=50,
choices=RackStatusChoices,
default=RackStatusChoices.STATUS_ACTIVE
)
role = models.ForeignKey(
to='dcim.RackRole',
@@ -552,6 +553,14 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'comments',
]
STATUS_CLASS_MAP = {
RackStatusChoices.STATUS_RESERVED: 'warning',
RackStatusChoices.STATUS_AVAILABLE: 'success',
RackStatusChoices.STATUS_PLANNED: 'info',
RackStatusChoices.STATUS_ACTIVE: 'primary',
RackStatusChoices.STATUS_DEPRECATED: 'danger',
}
class Meta:
ordering = ['site', 'group', 'name']
unique_together = [
@@ -644,7 +653,7 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
return ""
def get_status_class(self):
return STATUS_CLASSES[self.status]
return self.STATUS_CLASS_MAP.get(self.status)
def get_rack_units(self, face=RACK_FACE_FRONT, exclude=None, remove_redundant=False):
"""