Skip to content

Commit a99d14c

Browse files
committed
Closes #7924: Include child groups on contact group view
1 parent 68f322a commit a99d14c

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

docs/release-notes/version-3.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [#7812](https://github.com/netbox-community/netbox/issues/7812) - Enable change logging for image attachments
1616
* [#7858](https://github.com/netbox-community/netbox/issues/7858) - Standardize the representation of content types across import & export functions
1717
* [#7884](https://github.com/netbox-community/netbox/issues/7884) - Add FHRP groups column to interface tables
18+
* [#7924](https://github.com/netbox-community/netbox/issues/7924) - Include child groups on contact group view
1819
* [#7925](https://github.com/netbox-community/netbox/issues/7925) - Linkify contact phone and email attributes
1920

2021
### Bug Fixes

netbox/templates/tenancy/contactgroup.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,30 @@ <h5 class="card-header">
5050
</div>
5151
<div class="col col-md-6">
5252
{% include 'inc/panels/custom_fields.html' %}
53+
<div class="card">
54+
<h5 class="card-header">
55+
Child Groups
56+
</h5>
57+
<div class="card-body">
58+
{% include 'inc/table.html' with table=child_groups_table %}
59+
</div>
60+
{% if perms.tenancy.add_contactgroup %}
61+
<div class="card-footer text-end noprint">
62+
<a href="{% url 'tenancy:contactgroup_add' %}?parent={{ object.pk }}" class="btn btn-sm btn-primary">
63+
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Contact Group
64+
</a>
65+
</div>
66+
{% endif %}
67+
</div>
5368
{% plugin_right_page object %}
5469
</div>
5570
</div>
5671
<div class="row mb-3">
5772
<div class="col col-md-12">
5873
<div class="card">
59-
<div class="card-header">
60-
Tenants
61-
</div>
74+
<h5 class="card-header">
75+
Contacts
76+
</h5>
6277
<div class="card-body">
6378
{% include 'inc/table.html' with table=contacts_table %}
6479
</div>

netbox/tenancy/views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,25 @@ class ContactGroupView(generic.ObjectView):
168168
queryset = ContactGroup.objects.all()
169169

170170
def get_extra_context(self, request, instance):
171+
child_groups = ContactGroup.objects.add_related_count(
172+
ContactGroup.objects.all(),
173+
Contact,
174+
'group',
175+
'contact_count',
176+
cumulative=True
177+
).restrict(request.user, 'view').filter(
178+
parent__in=instance.get_descendants(include_self=True)
179+
)
180+
child_groups_table = tables.ContactGroupTable(child_groups)
181+
171182
contacts = Contact.objects.restrict(request.user, 'view').filter(
172183
group=instance
173184
)
174185
contacts_table = tables.ContactTable(contacts, exclude=('group',))
175186
paginate_table(contacts_table, request)
176187

177188
return {
189+
'child_groups_table': child_groups_table,
178190
'contacts_table': contacts_table,
179191
}
180192

0 commit comments

Comments
 (0)