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:
@@ -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,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user