Closes #10545: Standardize description & comment fields on primary models (#10834)

* Standardize description & comments fields on primary models

* Update REST API serializers

* Update forms

* Update tables

* Update templates
This commit is contained in:
Jeremy Stretch
2022-11-04 08:28:09 -04:00
committed by GitHub
parent 8ea0bb75c1
commit acc750ad70
105 changed files with 1014 additions and 534 deletions

View File

@@ -18,7 +18,7 @@ from dcim.constants import *
from extras.models import ConfigContextModel
from extras.querysets import ConfigContextModelQuerySet
from netbox.config import ConfigItem
from netbox.models import OrganizationalModel, NetBoxModel
from netbox.models import OrganizationalModel, PrimaryModel
from utilities.choices import ColorChoices
from utilities.fields import ColorField, NaturalOrderingField
from .device_components import *
@@ -54,7 +54,7 @@ class Manufacturer(OrganizationalModel):
return reverse('dcim:manufacturer', args=[self.pk])
class DeviceType(NetBoxModel, WeightMixin):
class DeviceType(PrimaryModel, WeightMixin):
"""
A DeviceType represents a particular make (Manufacturer) and model of device. It specifies rack height and depth, as
well as high-level functional role(s).
@@ -117,9 +117,6 @@ class DeviceType(NetBoxModel, WeightMixin):
upload_to='devicetype-images',
blank=True
)
comments = models.TextField(
blank=True
)
clone_fields = (
'manufacturer', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'weight', 'weight_unit',
@@ -298,7 +295,7 @@ class DeviceType(NetBoxModel, WeightMixin):
return self.subdevice_role == SubdeviceRoleChoices.ROLE_CHILD
class ModuleType(NetBoxModel, WeightMixin):
class ModuleType(PrimaryModel, WeightMixin):
"""
A ModuleType represents a hardware element that can be installed within a device and which houses additional
components; for example, a line card within a chassis-based switch such as the Cisco Catalyst 6500. Like a
@@ -318,9 +315,6 @@ class ModuleType(NetBoxModel, WeightMixin):
blank=True,
help_text='Discrete part number (optional)'
)
comments = models.TextField(
blank=True
)
# Generic relations
images = GenericRelation(
@@ -443,7 +437,7 @@ class Platform(OrganizationalModel):
return reverse('dcim:platform', args=[self.pk])
class Device(NetBoxModel, ConfigContextModel):
class Device(PrimaryModel, ConfigContextModel):
"""
A Device represents a piece of physical hardware mounted within a Rack. Each Device is assigned a DeviceType,
DeviceRole, and (optionally) a Platform. Device names are not required, however if one is set it must be unique.
@@ -587,9 +581,6 @@ class Device(NetBoxModel, ConfigContextModel):
null=True,
validators=[MaxValueValidator(255)]
)
comments = models.TextField(
blank=True
)
# Generic relations
contacts = GenericRelation(
@@ -906,7 +897,7 @@ class Device(NetBoxModel, ConfigContextModel):
return round(total_weight / 1000, 2)
class Module(NetBoxModel, ConfigContextModel):
class Module(PrimaryModel, ConfigContextModel):
"""
A Module represents a field-installable component within a Device which may itself hold multiple device components
(for example, a line card within a chassis switch). Modules are instantiated from ModuleTypes.
@@ -939,9 +930,6 @@ class Module(NetBoxModel, ConfigContextModel):
verbose_name='Asset tag',
help_text='A unique tag used to identify this device'
)
comments = models.TextField(
blank=True
)
clone_fields = ('device', 'module_type')
@@ -1019,7 +1007,7 @@ class Module(NetBoxModel, ConfigContextModel):
# Virtual chassis
#
class VirtualChassis(NetBoxModel):
class VirtualChassis(PrimaryModel):
"""
A collection of Devices which operate with a shared control plane (e.g. a switch stack).
"""