[PR #10312] [MERGED] Fixes #10247: Allow changing selected device/VM when creating a new component #13609

Closed
opened 2025-12-29 23:19:50 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10312
Author: @jeremystretch
Created: 9/9/2022
Status: Merged
Merged: 9/15/2022
Merged by: @jeremystretch

Base: developHead: 10247-vminterface-create


📝 Commits (10+)

📊 Changes

25 files changed (+522 additions, -629 deletions)

View changed files

📝 netbox/dcim/forms/bulk_create.py (+13 -12)
📝 netbox/dcim/forms/models.py (+146 -101)
📝 netbox/dcim/forms/object_create.py (+178 -80)
📝 netbox/dcim/models/device_components.py (+13 -11)
📝 netbox/dcim/tables/template_code.py (+1 -1)
📝 netbox/dcim/tests/test_forms.py (+10 -8)
📝 netbox/dcim/tests/test_views.py (+92 -109)
📝 netbox/dcim/views.py (+15 -82)
📝 netbox/netbox/views/generic/bulk_views.py (+9 -8)
📝 netbox/netbox/views/generic/object_views.py (+12 -20)
netbox/templates/dcim/component_template_create.html (+0 -38)
netbox/templates/dcim/device_component_edit.html (+0 -16)
netbox/templates/dcim/frontporttemplate_create.html (+0 -7)
netbox/templates/dcim/inventoryitem_create.html (+0 -17)
netbox/templates/dcim/inventoryitemtemplate_create.html (+0 -17)
netbox/templates/dcim/modulebaytemplate_create.html (+0 -7)
📝 netbox/templates/generic/object_edit.html (+5 -3)
netbox/templates/virtualization/vminterface_edit.html (+0 -69)
📝 netbox/utilities/forms/fields/expandable.py (+1 -1)
📝 netbox/utilities/testing/views.py (+3 -2)

...and 5 more files

📄 Description

Fixes: #10247

This work affects all device components, all device component templates, and VM interfaces. At a high level, we've switched from rendering two individual forms for component creation to a single new per-model creation form, which inherits from both ComponentCreateForm as well as the pertinent model form. This enables us to efficiently render the form and ditch a number of custom templates.

patterned_fields on the component creation views has been replaced with replication_fields, which is now defined on the form for more robust validation. Additionally, name_pattern and label_pattern have been renamed to name and label, and now replace the model form fields of the same names.


🔄 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/10312 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 9/9/2022 **Status:** ✅ Merged **Merged:** 9/15/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `10247-vminterface-create` --- ### 📝 Commits (10+) - [`4988c7b`](https://github.com/netbox-community/netbox/commit/4988c7b7d2aa686000d3fbc7ff9e8021b6c113a9) Initial work on #10247 - [`623a7e9`](https://github.com/netbox-community/netbox/commit/623a7e9a2cdb58dd90c6208c23cf566f8c147d30) Continued work on #10247 - [`305701b`](https://github.com/netbox-community/netbox/commit/305701b3873c7b8fe0405c96f2c0d949cfac4625) Clean up component creation tests - [`21fe202`](https://github.com/netbox-community/netbox/commit/21fe2025974cb969663da885cc37e844be3a6d1c) Move valdiation of replicated field to form - [`5888038`](https://github.com/netbox-community/netbox/commit/588803899658f724d9e1a192c3680cedeff954b2) Clean up ordering of fields in component creation forms - [`f055235`](https://github.com/netbox-community/netbox/commit/f055235ef1d7594b267f82821a885f0144e431fe) Omit fieldset header if none - [`83e5ba4`](https://github.com/netbox-community/netbox/commit/83e5ba433a9b2a7100eda75c87835f37a67d7688) Clean up ordering of fields in component template creation forms - [`bd37cca`](https://github.com/netbox-community/netbox/commit/bd37cca0aea4cd8b8120aedeb8bd8ac8ae84242c) View tests should not move component templates to new device type - [`1fd23da`](https://github.com/netbox-community/netbox/commit/1fd23daa075807ac3dd606a46605024ee634ff2f) Define replication_fields on VMInterfaceCreateForm - [`0d39efd`](https://github.com/netbox-community/netbox/commit/0d39efdc44ec8ae1b64e98e5cbdd29420136bb33) Clean up expandable field help texts ### 📊 Changes **25 files changed** (+522 additions, -629 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/forms/bulk_create.py` (+13 -12) 📝 `netbox/dcim/forms/models.py` (+146 -101) 📝 `netbox/dcim/forms/object_create.py` (+178 -80) 📝 `netbox/dcim/models/device_components.py` (+13 -11) 📝 `netbox/dcim/tables/template_code.py` (+1 -1) 📝 `netbox/dcim/tests/test_forms.py` (+10 -8) 📝 `netbox/dcim/tests/test_views.py` (+92 -109) 📝 `netbox/dcim/views.py` (+15 -82) 📝 `netbox/netbox/views/generic/bulk_views.py` (+9 -8) 📝 `netbox/netbox/views/generic/object_views.py` (+12 -20) ➖ `netbox/templates/dcim/component_template_create.html` (+0 -38) ➖ `netbox/templates/dcim/device_component_edit.html` (+0 -16) ➖ `netbox/templates/dcim/frontporttemplate_create.html` (+0 -7) ➖ `netbox/templates/dcim/inventoryitem_create.html` (+0 -17) ➖ `netbox/templates/dcim/inventoryitemtemplate_create.html` (+0 -17) ➖ `netbox/templates/dcim/modulebaytemplate_create.html` (+0 -7) 📝 `netbox/templates/generic/object_edit.html` (+5 -3) ➖ `netbox/templates/virtualization/vminterface_edit.html` (+0 -69) 📝 `netbox/utilities/forms/fields/expandable.py` (+1 -1) 📝 `netbox/utilities/testing/views.py` (+3 -2) _...and 5 more files_ </details> ### 📄 Description ### Fixes: #10247 This work affects all device components, all device component templates, and VM interfaces. At a high level, we've switched from rendering two individual forms for component creation to a single new per-model creation form, which inherits from both `ComponentCreateForm` as well as the pertinent model form. This enables us to efficiently render the form and ditch a number of custom templates. `patterned_fields` on the component creation views has been replaced with `replication_fields`, which is now defined on the form for more robust validation. Additionally, `name_pattern` and `label_pattern` have been renamed to `name` and `label`, and now replace the model form fields of the same names. --- <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-29 23:19:50 +01:00
adam closed this issue 2025-12-29 23:19:50 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13609