mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 20:06:25 -06:00
Perform is_primary validation on MACAddress model and just check if one already exists for the interface
This commit is contained in:
parent
3a7a4f83d6
commit
5029dd4eaf
@ -1516,3 +1516,12 @@ class MACAddress(PrimaryModel):
|
||||
|
||||
def __str__(self):
|
||||
return f'{str(self.mac_address)} {self.assigned_object}'
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
if self.is_primary and self.assigned_object:
|
||||
if self.assigned_object.mac_addresses.filter(is_primary=True).exists():
|
||||
raise ValidationError({
|
||||
'is_primary': _("There is already a primary MAC address for this interface.")
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user