[PR #19008] [MERGED] Fixes #18245: Make DeviceRole Hierarchical #15499

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19008
Author: @arthanson
Created: 3/25/2025
Status: Merged
Merged: 3/28/2025
Merged by: @jnovinger

Base: featureHead: 18981-device-role


📝 Commits (10+)

📊 Changes

25 files changed (+327 additions, -55 deletions)

View changed files

📝 docs/models/dcim/devicerole.md (+4 -0)
📝 netbox/dcim/api/serializers_/nested.py (+7 -0)
📝 netbox/dcim/api/serializers_/roles.py (+9 -4)
📝 netbox/dcim/filtersets.py (+29 -4)
📝 netbox/dcim/forms/bulk_edit.py (+8 -2)
📝 netbox/dcim/forms/bulk_import.py (+13 -1)
📝 netbox/dcim/forms/filtersets.py (+5 -0)
📝 netbox/dcim/forms/model_forms.py (+9 -2)
📝 netbox/dcim/graphql/types.py (+2 -0)
netbox/dcim/migrations/0203_device_role_nested.py (+65 -0)
netbox/dcim/migrations/0204_device_role_rebuild.py (+22 -0)
📝 netbox/dcim/models/devices.py (+4 -2)
📝 netbox/dcim/tables/devices.py (+1 -1)
📝 netbox/dcim/tests/test_api.py (+8 -8)
📝 netbox/dcim/tests/test_filtersets.py (+94 -16)
📝 netbox/dcim/tests/test_models.py (+2 -1)
📝 netbox/dcim/tests/test_views.py (+9 -4)
📝 netbox/extras/filtersets.py (+3 -1)
📝 netbox/extras/forms/filtersets.py (+2 -2)
📝 netbox/extras/tests/test_filtersets.py (+2 -1)

...and 5 more files

📄 Description

Fixes: #18245

Made DeviceRoles hierarchical, had to also change the filtersets for Device, ConfigContext and VirtualMachine to use the TreeNodeMultipleChoiceFilter.

Note: The model was changed to use NestedGroupModel, a side-effect of this is it also adds comments field, but I thought that was better then doing a one-off just for DeviceRole and having to define the fields, validators, etc.. - keeps everything DRY / consistent.

Monosnap Device Roles | NetBox 2025-03-26 12-53-04
Monosnap Devices | NetBox 2025-03-26 12-54-48
Monosnap Editing device role trol1 | NetBox 2025-03-26 12-53-33


🔄 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/19008 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 3/25/2025 **Status:** ✅ Merged **Merged:** 3/28/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `feature` ← **Head:** `18981-device-role` --- ### 📝 Commits (10+) - [`b5b1827`](https://github.com/netbox-community/netbox/commit/b5b18278934847dc7fe8b90fabf889808d094586) 18981 Make Device Roles Hierarchical - [`0b153f4`](https://github.com/netbox-community/netbox/commit/0b153f42deeae9c3fac611953bf957669b8ff00c) 18981 forms, serializer - [`140aaee`](https://github.com/netbox-community/netbox/commit/140aaee9c63581bff7a12ea3488e9db715096b19) 18981 fix tests - [`a307e9e`](https://github.com/netbox-community/netbox/commit/a307e9e141b3a4cc75f6f653771a5c6622e7a61c) 18981 fix tests - [`b38acca`](https://github.com/netbox-community/netbox/commit/b38accac66561cf28c22a2e8f4531f5806007ac1) 18981 fix tests - [`86458d2`](https://github.com/netbox-community/netbox/commit/86458d28e31afa146ab7022f25c19b0480a94809) 18981 fix tests - [`ba23d94`](https://github.com/netbox-community/netbox/commit/ba23d94b5811738d3141ac9881fb87932da702f2) 18981 fix tests - [`5a3faa7`](https://github.com/netbox-community/netbox/commit/5a3faa7eb3475fb6a396c83a4185d4c18fe4afc7) Merge branch 'feature' into 18981-device-role - [`86a321b`](https://github.com/netbox-community/netbox/commit/86a321b6b226925076854c235674807febb2ea15) 18981 fix migration merge - [`ddf580a`](https://github.com/netbox-community/netbox/commit/ddf580a6e6e78e07c739d2f2938088d371f2dee5) 18981 fix tests ### 📊 Changes **25 files changed** (+327 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `docs/models/dcim/devicerole.md` (+4 -0) 📝 `netbox/dcim/api/serializers_/nested.py` (+7 -0) 📝 `netbox/dcim/api/serializers_/roles.py` (+9 -4) 📝 `netbox/dcim/filtersets.py` (+29 -4) 📝 `netbox/dcim/forms/bulk_edit.py` (+8 -2) 📝 `netbox/dcim/forms/bulk_import.py` (+13 -1) 📝 `netbox/dcim/forms/filtersets.py` (+5 -0) 📝 `netbox/dcim/forms/model_forms.py` (+9 -2) 📝 `netbox/dcim/graphql/types.py` (+2 -0) ➕ `netbox/dcim/migrations/0203_device_role_nested.py` (+65 -0) ➕ `netbox/dcim/migrations/0204_device_role_rebuild.py` (+22 -0) 📝 `netbox/dcim/models/devices.py` (+4 -2) 📝 `netbox/dcim/tables/devices.py` (+1 -1) 📝 `netbox/dcim/tests/test_api.py` (+8 -8) 📝 `netbox/dcim/tests/test_filtersets.py` (+94 -16) 📝 `netbox/dcim/tests/test_models.py` (+2 -1) 📝 `netbox/dcim/tests/test_views.py` (+9 -4) 📝 `netbox/extras/filtersets.py` (+3 -1) 📝 `netbox/extras/forms/filtersets.py` (+2 -2) 📝 `netbox/extras/tests/test_filtersets.py` (+2 -1) _...and 5 more files_ </details> ### 📄 Description ### Fixes: #18245 Made DeviceRoles hierarchical, had to also change the filtersets for Device, ConfigContext and VirtualMachine to use the TreeNodeMultipleChoiceFilter. **Note:** The model was changed to use NestedGroupModel, a side-effect of this is it also adds comments field, but I thought that was better then doing a one-off just for DeviceRole and having to define the fields, validators, etc.. - keeps everything DRY / consistent. ![Monosnap Device Roles | NetBox 2025-03-26 12-53-04](https://github.com/user-attachments/assets/605df190-a356-4e06-84a0-743d40973992) ![Monosnap Devices | NetBox 2025-03-26 12-54-48](https://github.com/user-attachments/assets/39d3348e-a3a3-4e59-b5c9-24446889f6f4) ![Monosnap Editing device role trol1 | NetBox 2025-03-26 12-53-33](https://github.com/user-attachments/assets/2df9798a-f9d4-4163-9f55-7a700b9128de) --- <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:19 +01:00
adam closed this issue 2025-12-30 00:22:19 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15499