瀏覽代碼

14810 add contacts to service

Arthur 1 年之前
父節點
當前提交
0bfb9777be
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. 2 1
      netbox/ipam/models/services.py
  2. 5 0
      netbox/ipam/views.py

+ 2 - 1
netbox/ipam/models/services.py

@@ -8,6 +8,7 @@ from django.utils.translation import gettext_lazy as _
 from ipam.choices import *
 from ipam.constants import *
 from netbox.models import PrimaryModel
+from netbox.models.features import ContactsMixin
 from utilities.data import array_to_string
 
 __all__ = (
@@ -62,7 +63,7 @@ class ServiceTemplate(ServiceBase, PrimaryModel):
         return reverse('ipam:servicetemplate', args=[self.pk])
 
 
-class Service(ServiceBase, PrimaryModel):
+class Service(ContactsMixin, ServiceBase, PrimaryModel):
     """
     A Service represents a layer-four service (e.g. HTTP or SSH) running on a Device or VirtualMachine. A Service may
     optionally be tied to one or more specific IPAddresses belonging to its parent.

+ 5 - 0
netbox/ipam/views.py

@@ -1280,3 +1280,8 @@ class ServiceBulkDeleteView(generic.BulkDeleteView):
     queryset = Service.objects.prefetch_related('device', 'virtual_machine')
     filterset = filtersets.ServiceFilterSet
     table = tables.ServiceTable
+
+
+@register_model_view(Service, 'contacts')
+class ServiceContactsView(ObjectContactsView):
+    queryset = Service.objects.all()