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

Check for extraneous custom field data on clean()

This commit is contained in:
Jeremy Stretch
2020-11-12 12:18:31 -05:00
parent aed25fea3a
commit 4a8a1ce45c
9 changed files with 69 additions and 6 deletions

View File

@@ -155,6 +155,8 @@ class Cable(ChangeLoggedModel, CustomFieldModel):
def clean(self):
from circuits.models import CircuitTermination
super().clean()
# Validate that termination A exists
if not hasattr(self, 'termination_a_type'):
raise ValidationError('Termination A type has not been specified')

View File

@@ -254,6 +254,7 @@ class DeviceType(ChangeLoggedModel, CustomFieldModel):
return yaml.dump(dict(data), sort_keys=False)
def clean(self):
super().clean()
# If editing an existing DeviceType to have a larger u_height, first validate that *all* instances of it have
# room to expand within their racks. This validation will impose a very high performance penalty when there are
@@ -634,7 +635,6 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
super().validate_unique(exclude)
def clean(self):
super().clean()
# Validate site/rack combination
@@ -917,6 +917,7 @@ class VirtualChassis(ChangeLoggedModel, CustomFieldModel):
return reverse('dcim:virtualchassis', kwargs={'pk': self.pk})
def clean(self):
super().clean()
# Verify that the selected master device has been assigned to this VirtualChassis. (Skip when creating a new
# VirtualChassis.)

View File

@@ -64,6 +64,7 @@ class PowerPanel(ChangeLoggedModel, CustomFieldModel):
)
def clean(self):
super().clean()
# RackGroup must belong to assigned Site
if self.rack_group and self.rack_group.site != self.site:
@@ -172,6 +173,7 @@ class PowerFeed(ChangeLoggedModel, PathEndpoint, CableTermination, CustomFieldMo
)
def clean(self):
super().clean()
# Rack must belong to same Site as PowerPanel
if self.rack and self.rack.site != self.power_panel.site:

View File

@@ -296,6 +296,7 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
return reverse('dcim:rack', args=[self.pk])
def clean(self):
super().clean()
# Validate outer dimensions and unit
if (self.outer_width is not None or self.outer_depth is not None) and not self.outer_unit:
@@ -602,6 +603,7 @@ class RackReservation(ChangeLoggedModel, CustomFieldModel):
return reverse('dcim:rackreservation', args=[self.pk])
def clean(self):
super().clean()
if hasattr(self, 'rack') and self.units: