mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
simplify ObjectContactsView
This commit is contained in:
parent
c3b4043ebf
commit
2a2de3696b
@ -17,7 +17,7 @@ class ObjectContactsView(generic.ObjectChildrenView):
|
|||||||
template_name = 'tenancy/object_contacts.html'
|
template_name = 'tenancy/object_contacts.html'
|
||||||
tab = ViewTab(
|
tab = ViewTab(
|
||||||
label=_('Contacts'),
|
label=_('Contacts'),
|
||||||
badge=lambda obj: obj.contacts.count(),
|
badge=lambda obj: obj.get_contacts().count(),
|
||||||
permission='tenancy.view_contactassignment',
|
permission='tenancy.view_contactassignment',
|
||||||
weight=5000
|
weight=5000
|
||||||
)
|
)
|
||||||
@ -28,19 +28,7 @@ class ObjectContactsView(generic.ObjectChildrenView):
|
|||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_children(self, request, parent):
|
def get_children(self, request, parent):
|
||||||
return ContactAssignment.objects.restrict(request.user, 'view').filter(
|
return parent.get_contacts().restrict(request.user, 'view').order_by('priority', 'contact', 'role')
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user