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

Closes #10371: Add operational status field for modules

This commit is contained in:
jeremystretch
2022-12-09 10:43:29 -05:00
parent b2f34cec19
commit 97aa40f7a8
17 changed files with 123 additions and 29 deletions

View File

@@ -925,6 +925,11 @@ class Module(PrimaryModel, ConfigContextModel):
on_delete=models.PROTECT,
related_name='instances'
)
status = models.CharField(
max_length=50,
choices=ModuleStatusChoices,
default=ModuleStatusChoices.STATUS_ACTIVE
)
serial = models.CharField(
max_length=50,
blank=True,
@@ -939,7 +944,7 @@ class Module(PrimaryModel, ConfigContextModel):
help_text=_('A unique tag used to identify this device')
)
clone_fields = ('device', 'module_type')
clone_fields = ('device', 'module_type', 'status')
class Meta:
ordering = ('module_bay',)
@@ -950,6 +955,9 @@ class Module(PrimaryModel, ConfigContextModel):
def get_absolute_url(self):
return reverse('dcim:module', args=[self.pk])
def get_status_color(self):
return ModuleStatusChoices.colors.get(self.status)
def clean(self):
super().clean()