Closes #2643: Add description field to console/power components and device bays

This commit is contained in:
Jeremy Stretch
2019-02-20 14:34:05 -05:00
parent 0a06d92c2e
commit bb6fb81fc0
12 changed files with 181 additions and 54 deletions

View File

@@ -46,6 +46,10 @@ class ComponentTemplateModel(models.Model):
class ComponentModel(models.Model):
description = models.CharField(
max_length=100,
blank=True
)
class Meta:
abstract = True
@@ -1745,7 +1749,7 @@ class ConsolePort(CableTermination, ComponentModel):
objects = DeviceComponentManager()
tags = TaggableManager(through=TaggedItem)
csv_headers = ['device', 'name']
csv_headers = ['device', 'name', 'description']
class Meta:
ordering = ['device', 'name']
@@ -1761,6 +1765,7 @@ class ConsolePort(CableTermination, ComponentModel):
return (
self.device.identifier,
self.name,
self.description,
)
@@ -1788,7 +1793,7 @@ class ConsoleServerPort(CableTermination, ComponentModel):
objects = DeviceComponentManager()
tags = TaggableManager(through=TaggedItem)
csv_headers = ['device', 'name']
csv_headers = ['device', 'name', 'description']
class Meta:
unique_together = ['device', 'name']
@@ -1803,6 +1808,7 @@ class ConsoleServerPort(CableTermination, ComponentModel):
return (
self.device.identifier,
self.name,
self.description,
)
@@ -1841,7 +1847,7 @@ class PowerPort(CableTermination, ComponentModel):
class Meta:
ordering = ['device', 'name']
unique_together = ['device', 'name']
unique_together = ['device', 'name', 'description']
def __str__(self):
return self.name
@@ -1853,6 +1859,7 @@ class PowerPort(CableTermination, ComponentModel):
return (
self.device.identifier,
self.name,
self.description,
)
@@ -1883,7 +1890,7 @@ class PowerOutlet(CableTermination, ComponentModel):
csv_headers = ['device', 'name']
class Meta:
unique_together = ['device', 'name']
unique_together = ['device', 'name', 'description']
def __str__(self):
return self.name
@@ -1895,6 +1902,7 @@ class PowerOutlet(CableTermination, ComponentModel):
return (
self.device.identifier,
self.name,
self.description,
)
@@ -1973,10 +1981,6 @@ class Interface(CableTermination, ComponentModel):
verbose_name='OOB Management',
help_text='This interface is used only for out-of-band management'
)
description = models.CharField(
max_length=100,
blank=True
)
mode = models.PositiveSmallIntegerField(
choices=IFACE_MODE_CHOICES,
blank=True,
@@ -2193,10 +2197,6 @@ class FrontPort(CableTermination, ComponentModel):
default=1,
validators=[MinValueValidator(1), MaxValueValidator(64)]
)
description = models.CharField(
max_length=100,
blank=True
)
objects = DeviceComponentManager()
tags = TaggableManager(through=TaggedItem)
@@ -2259,10 +2259,6 @@ class RearPort(CableTermination, ComponentModel):
default=1,
validators=[MinValueValidator(1), MaxValueValidator(64)]
)
description = models.CharField(
max_length=100,
blank=True
)
objects = DeviceComponentManager()
tags = TaggableManager(through=TaggedItem)
@@ -2314,7 +2310,7 @@ class DeviceBay(ComponentModel):
objects = DeviceComponentManager()
tags = TaggableManager(through=TaggedItem)
csv_headers = ['device', 'name', 'installed_device']
csv_headers = ['device', 'name', 'installed_device', 'description']
class Meta:
ordering = ['device', 'name']
@@ -2331,6 +2327,7 @@ class DeviceBay(ComponentModel):
self.device.identifier,
self.name,
self.installed_device.identifier if self.installed_device else None,
self.description,
)
def clean(self):
@@ -2400,10 +2397,6 @@ class InventoryItem(ComponentModel):
default=False,
verbose_name='Discovered'
)
description = models.CharField(
max_length=100,
blank=True
)
tags = TaggableManager(through=TaggedItem)