Skip to content

Commit 17799df

Browse files
arthansonjeremystretch
authored andcommitted
13764 Add contacts to IP views
1 parent 233b902 commit 17799df

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

netbox/ipam/models/ip.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from ipam.validators import DNSValidator
1919
from netbox.config import get_config
2020
from netbox.models import OrganizationalModel, PrimaryModel
21+
from netbox.models.features import ContactsMixin
2122

2223
__all__ = (
2324
'Aggregate',
@@ -74,7 +75,7 @@ def get_absolute_url(self):
7475
return reverse('ipam:rir', args=[self.pk])
7576

7677

77-
class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
78+
class Aggregate(ContactsMixin, GetAvailablePrefixesMixin, PrimaryModel):
7879
"""
7980
An aggregate exists at the root level of the IP address space hierarchy in NetBox. Aggregates are used to organize
8081
the hierarchy and track the overall utilization of available address space. Each Aggregate is assigned to a RIR.
@@ -206,7 +207,7 @@ def get_absolute_url(self):
206207
return reverse('ipam:role', args=[self.pk])
207208

208209

209-
class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
210+
class Prefix(ContactsMixin, GetAvailablePrefixesMixin, PrimaryModel):
210211
"""
211212
A Prefix represents an IPv4 or IPv6 network, including mask length. Prefixes can optionally be assigned to Sites and
212213
VRFs. A Prefix must be assigned a status and may optionally be assigned a used-define Role. A Prefix can also be
@@ -486,7 +487,7 @@ def get_utilization(self):
486487
return min(utilization, 100)
487488

488489

489-
class IPRange(PrimaryModel):
490+
class IPRange(ContactsMixin, PrimaryModel):
490491
"""
491492
A range of IP addresses, defined by start and end addresses.
492493
"""
@@ -695,7 +696,7 @@ def utilization(self):
695696
return min(float(child_count) / self.size * 100, 100)
696697

697698

698-
class IPAddress(PrimaryModel):
699+
class IPAddress(ContactsMixin, PrimaryModel):
699700
"""
700701
An IPAddress represents an individual IPv4 or IPv6 address and its mask. The mask length should match what is
701702
configured in the real world. (Typically, only loopback interfaces are configured with /32 or /128 masks.) Like

netbox/ipam/views.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from dcim.filtersets import InterfaceFilterSet
1010
from dcim.models import Interface, Site
1111
from netbox.views import generic
12+
from tenancy.views import ObjectContactsView
1213
from utilities.query import count_related
1314
from utilities.tables import get_table_ordering
1415
from utilities.views import ViewTab, register_model_view
@@ -405,6 +406,11 @@ class AggregateBulkDeleteView(generic.BulkDeleteView):
405406
table = tables.AggregateTable
406407

407408

409+
@register_model_view(Aggregate, 'contacts')
410+
class AggregateContactsView(ObjectContactsView):
411+
queryset = Aggregate.objects.all()
412+
413+
408414
#
409415
# Prefix/VLAN roles
410416
#
@@ -643,6 +649,11 @@ class PrefixBulkDeleteView(generic.BulkDeleteView):
643649
table = tables.PrefixTable
644650

645651

652+
@register_model_view(Prefix, 'contacts')
653+
class PrefixContactsView(ObjectContactsView):
654+
queryset = Prefix.objects.all()
655+
656+
646657
#
647658
# IP Ranges
648659
#
@@ -726,6 +737,11 @@ class IPRangeBulkDeleteView(generic.BulkDeleteView):
726737
table = tables.IPRangeTable
727738

728739

740+
@register_model_view(IPRange, 'contacts')
741+
class IPRangeContactsView(ObjectContactsView):
742+
queryset = IPRange.objects.all()
743+
744+
729745
#
730746
# IP addresses
731747
#
@@ -893,6 +909,11 @@ def get_children(self, request, parent):
893909
return parent.get_related_ips().restrict(request.user, 'view')
894910

895911

912+
@register_model_view(IPAddress, 'contacts')
913+
class IPAddressContactsView(ObjectContactsView):
914+
queryset = IPAddress.objects.all()
915+
916+
896917
#
897918
# VLAN groups
898919
#

0 commit comments

Comments
 (0)