Skip to content

[feature] Mass command execution from the device changelist selection - #1462

Draft
dee077 wants to merge 2 commits into
feature/1345-mass-command-admin-workflowfrom
feature/1347-mass-command-admin-action
Draft

[feature] Mass command execution from the device changelist selection#1462
dee077 wants to merge 2 commits into
feature/1345-mass-command-admin-workflowfrom
feature/1347-mass-command-admin-action

Conversation

@dee077

@dee077 dee077 commented Aug 26, 2026

Copy link
Copy Markdown
Member

Checklist

Reference to Existing Issue

Closes #1347.

Description of Changes

Until now a mass command could only target devices by organization, group or
location. This adds the second entry point of the workflow: the devices are
picked one by one on the device changelist and handed over to the same two step
wizard.

1. Action on the device changelist

New action on the ModelAdmin registered for Device:

Execute mass command
  • shown to the users who can add mass commands (connection.add_batchcommand),
    so the action follows the permissions of the wizard it opens
  • a selection spanning more than one organization is refused with an error
    message on the changelist, the same way the Change group action does; the
    wording matches the model and the REST API:
    All devices must belong to the same organization, unless it is a system wide
    command.
  • registered on DeviceAdmin itself, so it is available in the admin of the
    other modules too (eg. openwisp-monitoring)

2. Execute page (step 1)

The action renders the existing execute page, so both entry points share one
view, one form and one template:

type            Command type (required)
input           Rendered by execute-command.js according to the type
label           Short label to identify the mass command (required)
notes           Optional notes
organization    Prefilled with the organization of the selection, disabled
devices         Hidden field carrying the selected device UUIDs
  • the selection travels in the form and not in the session, so it cannot outlive
    the wizard it belongs to, and two tabs cannot overwrite each other
  • organization is prefilled and disabled, group and location are not
    rendered at all: the targets are already known, so the fields would only be
    decoration
  • the number of selected devices is shown as an admin message right above the
    Targets heading
  • the devices are scoped again on every render: a non superuser only keeps the
    devices of the organizations they manage, and a device deleted in the meantime
    invalidates the form instead of being silently dropped

3. Confirm page (step 2)

The selection is stored in the session together with the rest of the wizard, and
the device table of the confirm page is built from those UUIDs instead of
BatchCommand.dry_run(). Everything else is unchanged: the table is still the
changelist of the currently registered DeviceAdmin, devices can still be
excluded one by one, and the summary of the targets shows N selected devices.

4. Flow

device changelist → "Execute mass command" action
                          │
                          ▼
execute_mass_command() → refuses a selection of multiple organizations
                          │
                          ▼
BatchCommandExecutionForm(device_ids=selection) → execute page
                          │
                          ▼
POST → stored in session (device_ids included) → redirect (PRG)
                          │
                          ▼
GET /admin/connection/batchcommand/confirm/
                          │
                          ▼
POST → BatchCommand.execute(devices=selection)
                          │
                          ▼
launch_batch_command.delay(batch.pk)                ← Celery task
                          │
                          ▼
change page updates table, counters and paginator in real time

Screenshots

Mass command executed from the device changelist selection

Admin.action.webm

- Execute mass command action on the device changelist
- Device selection carried in a hidden form field, not the session
- Organization prefilled and disabled when devices are selected
- Group and location hidden when devices are selected
- Selected device count shown as a message above the targets
- Mixed organization selections refused on both entry points

Fixes #1347
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1ad65f7c-3c21-405c-bebf-56120a7eee64

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@dee077 dee077 changed the title [feature] Add mass command admin action to the device changelist #1347 [feature] Mass command execution from the device changelist selection Aug 26, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
openwisp_controller/connection/admin.py 1111 New feature adds the execute_mass_command admin action and device-selection flow, but no tests were added (the PR checklist "I have written new test cases" is unchecked and the diff contains no test files). Per project policy, new features must include tests covering them.
docs/user/shell-commands.rst 197 The mass-command workflow is documented ("Sending a Mass Command"), but this PR adds a new entry point from the device changelist and changes the execute page (organization prefilled/disabled, group/location hidden, selected-device count message). Documentation was not updated (checklist "I have updated the documentation" is unchecked).
Files Reviewed (4 files)
  • openwisp_controller/connection/admin.py
  • openwisp_controller/connection/static/connection/css/batch-command.css
  • openwisp_controller/connection/static/connection/js/execute-command.js
  • openwisp_controller/connection/templates/admin/connection/batch_command/execute_command.html

Fix these issues in Kilo Cloud


Reviewed by balanced · Input: 71.9K · Output: 28.7K · Cached: 711.9K

@dee077
dee077 marked this pull request as draft August 26, 2026 23:53
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.

1 participant