[PR #17995] [CLOSED] Fixes #17954 - Handle CircuitTerminations in Cable Bulk Import #15247

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17995
Author: @jsenecal
Created: 11/12/2024
Status: Closed

Base: developHead: 17954_cable_bulk_import_circuit_terminations


📝 Commits (4)

  • 2721455 Fixes #17954 - Handle CircuitTerminations in Cable Bulk Import
  • 98c2b2f Merge branch 'develop' into 17954_cable_bulk_import_circuit_terminations
  • ea34d7b Translate badge text and simplify implementation
  • 8660838 Update erroneous comment

📊 Changes

3 files changed (+57 additions, -7 deletions)

View changed files

📝 netbox/dcim/forms/bulk_import.py (+50 -7)
📝 netbox/templates/generic/bulk_import.html (+2 -0)
📝 netbox/utilities/forms/fields/csv.py (+5 -0)

📄 Description

Fixes: #17954

Add Support for Bulk Importing Cables Connected to Circuits

This pull request enhances the bulk import functionality for cables by allowing users to specify circuits as termination points on either side of a cable. Previously, only devices could be specified for cable terminations during bulk import which didn't allow for Cables to be connected to Circuit Terminations properly.

Key Changes:

  • Added Fields for Circuit Terminations:

    • Introduced side_a_circuit and side_b_circuit fields in the CableImportForm within dcim/forms/bulk_import.py.
    • These fields are optional and conditional, allowing users to specify a Circuit ID (cid) as a termination point.
  • Updated CableImportForm Validation Logic:

    • Modified the _clean_side method in CableImportForm to handle cases where a circuit is specified instead of a device.
    • Added validation to ensure that both a device and a circuit cannot be specified simultaneously for the same side.
    • Ensured that the termination object is correctly retrieved based on whether a device or circuit is provided.
    • Added checks to prevent connecting to a circuit termination that is already connected to a Provider Network.
  • Enhanced Bulk Import Template:

    • Updated bulk_import.html to display a "Conditional" tag for fields that are conditionally required, improving user experience during the import process.
  • Extended CSV Field Functionality:

    • Modified CSVModelChoiceField in utilities/forms/fields/csv.py to accept a conditional parameter.
    • This parameter is used to indicate fields that are conditionally required based on other form fields.

Benefits:

  • Improved Flexibility: Users can now bulk import cables that connect directly to circuits, not just devices.
  • Enhanced User Experience: Clearer form validation messages and template indicators help prevent import errors.
  • Increased Efficiency: Streamlines the process of importing large numbers of cables connected to circuits.

Usage Notes:

  • When importing, specify either a device or a circuit for each side of the cable—not both.
  • Ensure that the circuit terminations are not already connected to a Provider Network to avoid validation errors.

🔄 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/17995 **Author:** [@jsenecal](https://github.com/jsenecal) **Created:** 11/12/2024 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `17954_cable_bulk_import_circuit_terminations` --- ### 📝 Commits (4) - [`2721455`](https://github.com/netbox-community/netbox/commit/2721455082577ce37788be11b543940190e06d41) Fixes #17954 - Handle CircuitTerminations in Cable Bulk Import - [`98c2b2f`](https://github.com/netbox-community/netbox/commit/98c2b2f5049a5e84a47292fbb46cf5ae177aca9d) Merge branch 'develop' into 17954_cable_bulk_import_circuit_terminations - [`ea34d7b`](https://github.com/netbox-community/netbox/commit/ea34d7bce88e4f74743585b99c9e4058517b7400) Translate badge text and simplify implementation - [`8660838`](https://github.com/netbox-community/netbox/commit/8660838b36b85fe0e332650b937a059ffe1d29b7) Update erroneous comment ### 📊 Changes **3 files changed** (+57 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/forms/bulk_import.py` (+50 -7) 📝 `netbox/templates/generic/bulk_import.html` (+2 -0) 📝 `netbox/utilities/forms/fields/csv.py` (+5 -0) </details> ### 📄 Description ### Fixes: #17954 ### Add Support for Bulk Importing Cables Connected to Circuits This pull request enhances the bulk import functionality for cables by allowing users to specify circuits as termination points on either side of a cable. Previously, only devices could be specified for cable terminations during bulk import which didn't allow for Cables to be connected to Circuit Terminations properly. **Key Changes:** - **Added Fields for Circuit Terminations:** - Introduced `side_a_circuit` and `side_b_circuit` fields in the `CableImportForm` within `dcim/forms/bulk_import.py`. - These fields are optional and conditional, allowing users to specify a Circuit ID (`cid`) as a termination point. - **Updated CableImportForm Validation Logic:** - Modified the `_clean_side` method in `CableImportForm` to handle cases where a circuit is specified instead of a device. - Added validation to ensure that both a device and a circuit cannot be specified simultaneously for the same side. - Ensured that the termination object is correctly retrieved based on whether a device or circuit is provided. - Added checks to prevent connecting to a circuit termination that is already connected to a Provider Network. - **Enhanced Bulk Import Template:** - Updated `bulk_import.html` to display a "Conditional" tag for fields that are conditionally required, improving user experience during the import process. - **Extended CSV Field Functionality:** - Modified `CSVModelChoiceField` in `utilities/forms/fields/csv.py` to accept a `conditional` parameter. - This parameter is used to indicate fields that are conditionally required based on other form fields. **Benefits:** - **Improved Flexibility:** Users can now bulk import cables that connect directly to circuits, not just devices. - **Enhanced User Experience:** Clearer form validation messages and template indicators help prevent import errors. - **Increased Efficiency:** Streamlines the process of importing large numbers of cables connected to circuits. **Usage Notes:** - When importing, specify either a device or a circuit for each side of the cable—not both. - Ensure that the circuit terminations are not already connected to a Provider Network to avoid validation errors. --- <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:20:51 +01:00
adam closed this issue 2025-12-30 00:20:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15247