Misc cleanup, renaming

This commit is contained in:
Jeremy Stretch
2020-06-23 16:39:43 -04:00
parent 3feaf5f556
commit 381e7cd4e3
18 changed files with 82 additions and 92 deletions

View File

@@ -753,6 +753,7 @@ class IPAddress(ChangeLoggedModel, CustomFieldModel):
super().save(*args, **kwargs)
def to_objectchange(self, action):
# Annotate the assigned object, if any
return ObjectChange(
changed_object=self,
object_repr=str(self),
@@ -764,12 +765,15 @@ class IPAddress(ChangeLoggedModel, CustomFieldModel):
def to_csv(self):
# Determine if this IP is primary for a Device
is_primary = False
if self.address.version == 4 and getattr(self, 'primary_ip4_for', False):
is_primary = True
elif self.address.version == 6 and getattr(self, 'primary_ip6_for', False):
is_primary = True
else:
is_primary = False
obj_type = None
if self.assigned_object_type:
obj_type = f'{self.assigned_object_type.app_label}.{self.assigned_object_type.model}'
return (
self.address,
@@ -777,7 +781,7 @@ class IPAddress(ChangeLoggedModel, CustomFieldModel):
self.tenant.name if self.tenant else None,
self.get_status_display(),
self.get_role_display(),
'{}.{}'.format(self.assigned_object_type.app_label, self.assigned_object_type.model) if self.assigned_object_type else None,
obj_type,
self.assigned_object_id,
is_primary,
self.dns_name,