1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #7924: Include child groups on contact group view

This commit is contained in:
jeremystretch
2021-12-03 11:00:00 -05:00
parent 68f322a03b
commit a99d14c13f
3 changed files with 31 additions and 3 deletions

View File

@@ -168,6 +168,17 @@ class ContactGroupView(generic.ObjectView):
queryset = ContactGroup.objects.all()
def get_extra_context(self, request, instance):
child_groups = ContactGroup.objects.add_related_count(
ContactGroup.objects.all(),
Contact,
'group',
'contact_count',
cumulative=True
).restrict(request.user, 'view').filter(
parent__in=instance.get_descendants(include_self=True)
)
child_groups_table = tables.ContactGroupTable(child_groups)
contacts = Contact.objects.restrict(request.user, 'view').filter(
group=instance
)
@@ -175,6 +186,7 @@ class ContactGroupView(generic.ObjectView):
paginate_table(contacts_table, request)
return {
'child_groups_table': child_groups_table,
'contacts_table': contacts_table,
}