[PR #18885] [MERGED] 17170 Add ability to add contacts to multiple contact groups #15464

Closed
opened 2025-12-30 00:22:05 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18885
Author: @arthanson
Created: 3/12/2025
Status: Merged
Merged: 3/18/2025
Merged by: @jeremystretch

Base: featureHead: 17170-contact-groups


📝 Commits (10+)

📊 Changes

18 files changed (+204 additions, -78 deletions)

View changed files

📝 docs/models/tenancy/contact.md (+4 -2)
📝 netbox/templates/tenancy/contact.html (+12 -2)
📝 netbox/tenancy/api/serializers_/contacts.py (+8 -3)
📝 netbox/tenancy/api/views.py (+1 -1)
📝 netbox/tenancy/filtersets.py (+11 -6)
📝 netbox/tenancy/forms/bulk_edit.py (+14 -5)
📝 netbox/tenancy/forms/bulk_import.py (+4 -5)
📝 netbox/tenancy/forms/filtersets.py (+1 -1)
📝 netbox/tenancy/forms/model_forms.py (+6 -6)
📝 netbox/tenancy/graphql/types.py (+1 -1)
netbox/tenancy/migrations/0018_contact_groups.py (+68 -0)
📝 netbox/tenancy/models/contacts.py (+18 -11)
📝 netbox/tenancy/tables/contacts.py (+5 -5)
📝 netbox/tenancy/tests/test_api.py (+8 -6)
📝 netbox/tenancy/tests/test_filtersets.py (+13 -6)
📝 netbox/tenancy/tests/test_views.py (+16 -13)
📝 netbox/tenancy/views.py (+12 -3)
📝 netbox/utilities/testing/filtersets.py (+2 -2)

📄 Description

Fixes: #17170

Changed Contacts Group field to be M2M field so a contact can belong to multiple contact groups. There were some issues as ContactGroup is a nested model (so using TreeNode) which I don't think we have done before (allowing multiple assignments of a TreeNode field).

This caused an issue in utilities.testing.fitersets.py as it was expecting ModelMultipleChoiceField instead of TreeNodeModelMultipleChoiceField (which is derived from ModelMultipleChoiceField) so changed the assert to assertIsInstance: https://github.com/netbox-community/netbox/pull/18885/files#diff-27b47272104ca5b929872465d014bb392aacf97b3fc957695d85ebaa82171e40

Changed group references to groups as it is plural now.

ContactFilterSet was throwing a missing filter error when using group_id, group, needed to change it to contact_group_id, contact_group. Not completely sure why that was complaining with the change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/18885 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 3/12/2025 **Status:** ✅ Merged **Merged:** 3/18/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `17170-contact-groups` --- ### 📝 Commits (10+) - [`ea03358`](https://github.com/netbox-community/netbox/commit/ea03358752c046fdda9f17d2ac08bdd580a9cce5) 17170 Allow multiple Group assignments for Contacts - [`771a9a2`](https://github.com/netbox-community/netbox/commit/771a9a2d4f3eddc1453d2e804468e7c0b9a1dfba) 17170 update docs - [`c7827c7`](https://github.com/netbox-community/netbox/commit/c7827c796025915a21317e03ff629c070d7c38d1) 17170 update api, detail view, graphql - [`e1f8ff1`](https://github.com/netbox-community/netbox/commit/e1f8ff169c690b355e44b4298d3cdafc29f90f75) 17170 fixes - [`c7cb869`](https://github.com/netbox-community/netbox/commit/c7cb869f08098342256244f047341ebe447e8691) 17170 fixes - [`31dd765`](https://github.com/netbox-community/netbox/commit/31dd76559aed5cb969dfc777ef13d55378573a32) 17170 fixes - [`8c62465`](https://github.com/netbox-community/netbox/commit/8c62465b8170c84247543e8458a2ba4c0f1cd9bd) 17170 fixes - [`a843765`](https://github.com/netbox-community/netbox/commit/a843765d0c938012135f1f7eac2c21819e107bbe) 17170 fixes - [`1b2c96b`](https://github.com/netbox-community/netbox/commit/1b2c96bc7b4215feb16dae20c377bd88eda16295) 17170 fixes - [`5782ad8`](https://github.com/netbox-community/netbox/commit/5782ad813d76f2f8b69e5eb57dda1bba547629c9) 17170 fix bulk import ### 📊 Changes **18 files changed** (+204 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `docs/models/tenancy/contact.md` (+4 -2) 📝 `netbox/templates/tenancy/contact.html` (+12 -2) 📝 `netbox/tenancy/api/serializers_/contacts.py` (+8 -3) 📝 `netbox/tenancy/api/views.py` (+1 -1) 📝 `netbox/tenancy/filtersets.py` (+11 -6) 📝 `netbox/tenancy/forms/bulk_edit.py` (+14 -5) 📝 `netbox/tenancy/forms/bulk_import.py` (+4 -5) 📝 `netbox/tenancy/forms/filtersets.py` (+1 -1) 📝 `netbox/tenancy/forms/model_forms.py` (+6 -6) 📝 `netbox/tenancy/graphql/types.py` (+1 -1) ➕ `netbox/tenancy/migrations/0018_contact_groups.py` (+68 -0) 📝 `netbox/tenancy/models/contacts.py` (+18 -11) 📝 `netbox/tenancy/tables/contacts.py` (+5 -5) 📝 `netbox/tenancy/tests/test_api.py` (+8 -6) 📝 `netbox/tenancy/tests/test_filtersets.py` (+13 -6) 📝 `netbox/tenancy/tests/test_views.py` (+16 -13) 📝 `netbox/tenancy/views.py` (+12 -3) 📝 `netbox/utilities/testing/filtersets.py` (+2 -2) </details> ### 📄 Description ### Fixes: #17170 Changed Contacts Group field to be M2M field so a contact can belong to multiple contact groups. There were some issues as ContactGroup is a nested model (so using TreeNode) which I don't think we have done before (allowing multiple assignments of a TreeNode field). This caused an issue in utilities.testing.fitersets.py as it was expecting ModelMultipleChoiceField instead of TreeNodeModelMultipleChoiceField (which is derived from ModelMultipleChoiceField) so changed the assert to assertIsInstance: https://github.com/netbox-community/netbox/pull/18885/files#diff-27b47272104ca5b929872465d014bb392aacf97b3fc957695d85ebaa82171e40 Changed group references to groups as it is plural now. ContactFilterSet was throwing a missing filter error when using group_id, group, needed to change it to contact_group_id, contact_group. Not completely sure why that was complaining with the change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:22:05 +01:00
adam closed this issue 2025-12-30 00:22:05 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15464