mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Merge pull request #18444 from netbox-community/18433-fix-macaddress-primary-for-interface
Fixes: #18433 - Fix missing is_primary property on MACAddress model
This commit is contained in:
commit
cf64f3cc43
@ -1531,6 +1531,13 @@ class MACAddress(PrimaryModel):
|
|||||||
self._original_assigned_object_id = self.__dict__.get('assigned_object_id')
|
self._original_assigned_object_id = self.__dict__.get('assigned_object_id')
|
||||||
self._original_assigned_object_type_id = self.__dict__.get('assigned_object_type_id')
|
self._original_assigned_object_type_id = self.__dict__.get('assigned_object_type_id')
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def is_primary(self):
|
||||||
|
if self.assigned_object and hasattr(self.assigned_object, 'primary_mac_address'):
|
||||||
|
if self.assigned_object.primary_mac_address and self.assigned_object.primary_mac_address.pk == self.pk:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
super().clean()
|
super().clean()
|
||||||
if self._original_assigned_object_id and self._original_assigned_object_type_id:
|
if self._original_assigned_object_id and self._original_assigned_object_type_id:
|
||||||
|
Loading…
Reference in New Issue
Block a user