mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-26 18:38: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'
|
||||
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')
|
||||
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user