mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 01:06:11 -06:00
Make sure we bail out if field validation failed when importing modules
This commit is contained in:
parent
08a419ec7a
commit
472542b888
@ -54,13 +54,17 @@ class InterfaceCommonForm(forms.Form):
|
|||||||
class ModuleCommonForm(forms.Form):
|
class ModuleCommonForm(forms.Form):
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
cleaned_data = super().clean()
|
||||||
|
|
||||||
replicate_components = self.cleaned_data.get("replicate_components")
|
# Skip form validation if field validation already found errors.
|
||||||
adopt_components = self.cleaned_data.get("adopt_components")
|
if self.errors:
|
||||||
device = self.cleaned_data.get('device')
|
return cleaned_data
|
||||||
module_type = self.cleaned_data.get('module_type')
|
|
||||||
module_bay = self.cleaned_data.get('module_bay')
|
replicate_components = cleaned_data.get("replicate_components")
|
||||||
|
adopt_components = cleaned_data.get("adopt_components")
|
||||||
|
device = cleaned_data.get('device')
|
||||||
|
module_type = cleaned_data.get('module_type')
|
||||||
|
module_bay = cleaned_data.get('module_bay')
|
||||||
|
|
||||||
if adopt_components:
|
if adopt_components:
|
||||||
self.instance._adopt_components = True
|
self.instance._adopt_components = True
|
||||||
|
@ -961,7 +961,7 @@ class Module(PrimaryModel, ConfigContextModel):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
if self.module_bay.device != self.device:
|
if hasattr(self, "module_bay") and (self.module_bay.device != self.device):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
f"Module must be installed within a module bay belonging to the assigned device ({self.device})."
|
f"Module must be installed within a module bay belonging to the assigned device ({self.device})."
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user