Skip to content

Conversation

@pheus
Copy link
Contributor

@pheus pheus commented Dec 18, 2025

Fixes: #20320

This PR addresses the issue where the “Related Interfaces” selectors (Parent/Bridge/LAG) are disabled when bulk-editing interfaces from an object child view (e.g. device → interfaces) in v4.4.0.

Summary / Rationale

When bulk actions are invoked from an object child view (e.g. /dcim/devices/<pk>/interfaces/), the bulk edit action URL no longer carries the parent-scoping query parameter (e.g. device=<pk>). Without that context, the bulk edit form can’t scope/populate the related-interface fields, leaving them grayed out.

Proposed Changes

  • Enhance BulkEdit.get_context() to detect the “child view” case (presence of a parent object in the template context).
  • When applicable, inject the parent object’s primary key into the bulk edit action URL parameters (e.g. device=<parent.pk> / device_type=<parent.pk>), while preserving any existing request.GET parameters (and return_url when present).
  • Only add the parameter when it’s not already provided, to avoid altering behavior on global list views.

Tests Added

  • Added a unit test to confirm the parent object's PK is included in url_params when rendering a bulk action in a child-object context:
    • test_bulk_edit_get_context_child_object creates a DeviceType parent and verifies BulkEdit.get_context(context, Device) injects device_type=<parent.pk> into url_params when the template context includes object=<DeviceType>.
  • Also adjusted a plugin URL test to ensure the @skipIf decorator behaves correctly:
    • Moved the import of the dummy plugin model inside test_get_url_plugin_model so the module import doesn’t occur before the @skipIf condition is evaluated.

Notes / Open Question

I’m not 100% certain this is the preferred place to implement the fix (action context vs. view/template), but this approach keeps the change small and avoids duplicating templates.

How To Test

  1. Go to a device → Interfaces tab.
  2. Select multiple interfaces.
  3. Click Edit Selected.
  4. Confirm the Parent/Bridge/LAG fields are enabled and show relevant interface choices.
  5. Confirm bulk edit from the global Interfaces list behaves as before (no unintended scoping).
  6. Run the test suite (including plugin tests when netbox.tests.dummy_plugin is enabled) and confirm all tests pass.

Enhances `BulkEdit.get_context()` to include the parent object's
primary key in the URL parameters for child objects. This allows
proper association between parent-child objects during bulk edits.

Fixes netbox-community#20320
@pheus pheus marked this pull request as ready for review December 18, 2025 21:56
@jnovinger jnovinger requested review from a team and bctiemann and removed request for a team December 18, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Related Interfaces are grayed out on multi inferface edit

1 participant