Remove model_form check

This commit is contained in:
Daniel Sheppard 2023-12-28 10:33:00 -06:00
parent ec58b5338f
commit 2cc35b4e9f

View File

@ -369,19 +369,6 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
'primary_for_parent', _("Only IP addresses assigned to an interface can be designated as primary IPs.") 'primary_for_parent', _("Only IP addresses assigned to an interface can be designated as primary IPs.")
) )
if self.instance.pk:
prev_interface = self.instance.interface.first() or self.instance.vminterface.first()
# If the prev interface exists and does not match the new interface, we need to validate it isn't set as primary
# for the parent
if prev_interface and prev_interface != interface:
prev_parent = prev_interface.device or prev_interface.virtual_machine
# Check that the parent exists and if it is set as a primary ip.
if prev_parent and prev_parent.primary_ip4 == self.instance or prev_parent.primary_ip6 == self.instance:
self.add_error(
selected_objects[0],
_("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.
if interface and (address := self.cleaned_data.get('address')): if interface and (address := self.cleaned_data.get('address')):
if address.ip == address.network: if address.ip == address.network: