From 2a2de3696b8381293d419716ffb553cb7886ea4d Mon Sep 17 00:00:00 2001 From: Renato Almeida de Oliveira Zaroubin Date: Tue, 1 Apr 2025 00:29:01 +0000 Subject: [PATCH] simplify ObjectContactsView --- netbox/tenancy/views.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/netbox/tenancy/views.py b/netbox/tenancy/views.py index f17fec2ea..8f7e149d9 100644 --- a/netbox/tenancy/views.py +++ b/netbox/tenancy/views.py @@ -17,7 +17,7 @@ class ObjectContactsView(generic.ObjectChildrenView): template_name = 'tenancy/object_contacts.html' tab = ViewTab( label=_('Contacts'), - badge=lambda obj: obj.contacts.count(), + badge=lambda obj: obj.get_contacts().count(), permission='tenancy.view_contactassignment', weight=5000 ) @@ -28,19 +28,7 @@ class ObjectContactsView(generic.ObjectChildrenView): return super().dispatch(request, *args, **kwargs) def get_children(self, request, parent): - return ContactAssignment.objects.restrict(request.user, 'view').filter( - object_type=ContentType.objects.get_for_model(parent), - object_id=parent.pk - ).order_by('priority', 'contact', 'role') - - def get_table(self, *args, **kwargs): - table = super().get_table(*args, **kwargs) - - # Hide object columns - table.columns.hide('object_type') - table.columns.hide('object') - - return table + return parent.get_contacts().restrict(request.user, 'view').order_by('priority', 'contact', 'role') #