add primary ip and oob ip checkmark to ip address view

This commit is contained in:
Jamie Murphy 2023-06-26 22:29:50 +01:00
parent e5cea213c5
commit b45606d6ba
2 changed files with 34 additions and 0 deletions

View File

@ -849,6 +849,32 @@ class IPAddress(PrimaryModel):
return self.address.version
return None
@property
def is_oob_ip(self):
if self.assigned_object:
if self.family == 4:
if self.assigned_object.device.oob_ip4:
if self.assigned_object.device.oob_ip4.pk == self.pk:
return True
if self.family == 6:
if self.assigned_object.device.oob_ip6:
if self.assigned_object.device.oob_ip6.pk == self.pk:
return True
return False
@property
def is_primary_ip(self):
if self.assigned_object:
if self.family == 4:
if self.assigned_object.device.primary_ip4:
if self.assigned_object.device.primary_ip4.pk == self.pk:
return True
if self.family == 6:
if self.assigned_object.device.primary_ip6:
if self.assigned_object.device.primary_ip6.pk == self.pk:
return True
return False
def _set_mask_length(self, value):
"""
Expose the IPNetwork object's prefixlen attribute on the parent model so that it can be manipulated directly,

View File

@ -96,6 +96,14 @@
{% endfor %}
</td>
</tr>
<tr>
<td>Primary IP</td>
<td>{% checkmark object.is_primary_ip %}</td>
</tr>
<tr>
<td>OOB IP</td>
<td>{% checkmark object.is_oob_ip %}</td>
</tr>
</table>
</div>
</div>