1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Standardize on get_FOO_color() method for returning ChoiceField colors

This commit is contained in:
jeremystretch
2022-02-11 14:25:13 -05:00
parent 9cf9f1bdba
commit 1319b62acb
31 changed files with 81 additions and 60 deletions

View File

@@ -437,6 +437,9 @@ class Prefix(GetAvailablePrefixesMixin, NetBoxModel):
self.prefix.prefixlen = value
prefix_length = property(fset=_set_prefix_length)
def get_status_color(self):
return PrefixStatusChoices.colors.get(self.status)
def get_parents(self, include_self=False):
"""
Return all containing Prefixes in the hierarchy.
@@ -703,6 +706,9 @@ class IPRange(NetBoxModel):
self.end_address.prefixlen = value
prefix_length = property(fset=_set_prefix_length)
def get_status_color(self):
return IPRangeStatusChoices.colors.get(self.status)
def get_child_ips(self):
"""
Return all IPAddresses within this IPRange and VRF.
@@ -916,3 +922,9 @@ class IPAddress(NetBoxModel):
if self.address is not None:
self.address.prefixlen = value
mask_length = property(fset=_set_mask_length)
def get_status_color(self):
return IPAddressStatusChoices.colors.get(self.status)
def get_role_color(self):
return IPAddressRoleChoices.colors.get(self.role)

View File

@@ -211,6 +211,9 @@ class VLAN(NetBoxModel):
f"{self.group}"
})
def get_status_color(self):
return VLANStatusChoices.colors.get(self.status)
def get_interfaces(self):
# Return all device interfaces assigned to this VLAN
return Interface.objects.filter(