mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
Modify clean() on model and form to properly catch error
This commit is contained in:
parent
6aa4670c39
commit
b9b24d9399
@ -375,7 +375,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
|
|||||||
if prev_parent.primary_ip4 == self.instance or prev_parent.primary_ip6 == self.instance:
|
if prev_parent.primary_ip4 == self.instance or prev_parent.primary_ip6 == self.instance:
|
||||||
self.add_error(
|
self.add_error(
|
||||||
selected_objects[0],
|
selected_objects[0],
|
||||||
_("Cannot reassign IP address while it is designated as the primary ip for the parent object")
|
_("Cannot reassign IP address while it is designated as the primary IP for the parent object")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Do not allow assigning a network ID or broadcast address to an interface.
|
# Do not allow assigning a network ID or broadcast address to an interface.
|
||||||
|
@ -864,11 +864,9 @@ class IPAddress(PrimaryModel):
|
|||||||
is_primary = True
|
is_primary = True
|
||||||
|
|
||||||
if is_primary and (parent != original_parent):
|
if is_primary and (parent != original_parent):
|
||||||
raise ValidationError({
|
raise ValidationError(
|
||||||
'assigned_object': _(
|
_("Cannot reassign IP address while it is designated as the primary IP for the parent object")
|
||||||
"Cannot reassign IP address while it is designated as the primary IP for the parent object"
|
|
||||||
)
|
)
|
||||||
})
|
|
||||||
|
|
||||||
# Validate IP status selection
|
# Validate IP status selection
|
||||||
if self.status == IPAddressStatusChoices.STATUS_SLAAC and self.family != 6:
|
if self.status == IPAddressStatusChoices.STATUS_SLAAC and self.family != 6:
|
||||||
|
Loading…
Reference in New Issue
Block a user