Skip to content

[feature] Django admin view for Mass Command model#1420

Open
dee077 wants to merge 29 commits into
gsoc26-mass-commandsfrom
feature/1345-mass-command-admin-workflow
Open

[feature] Django admin view for Mass Command model#1420
dee077 wants to merge 29 commits into
gsoc26-mass-commandsfrom
feature/1345-mass-command-admin-workflow

Conversation

@dee077

@dee077 dee077 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1345.

Description of Changes

  • Add Django admin workflow for mass command execution with a custom change form
  • Improve admin changelist with better column layout, colored status, and link display
  • Used label (mandatory) and notes (optional) fields in the BatchCommand admin view.
  • Add affected_devices computed field to BatchCommand
  • Polish UI consistency with CSS updates for status indicators

Screenshot

Screencast.from.2026-07-03.00-47-45.webm

Todo:

  • Polish code
  • Test extensively with all edge cases
  • Write tests
  • Write docs

@dee077 dee077 self-assigned this Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 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: e8abd6ac-d33b-450d-995d-b60195b9dc90

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/1345-mass-command-admin-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@dee077 dee077 added enhancement gsoc Part of a Google Summer of Code project labels Jul 2, 2026
@dee077 dee077 moved this to In progress in [GSoC26] Mass Commands Jul 2, 2026
@dee077
dee077 force-pushed the feature/1344-mass-command-execution-pipeline branch 3 times, most recently from 989477b to 7c80797 Compare July 3, 2026 23:58
@dee077
dee077 force-pushed the feature/1345-mass-command-admin-workflow branch from dd0c0c1 to 432952e Compare July 3, 2026 23:59
@dee077
dee077 marked this pull request as ready for review July 6, 2026 21:21
@dee077
dee077 force-pushed the feature/1344-mass-command-execution-pipeline branch 2 times, most recently from c1afb08 to d8c3ea1 Compare July 11, 2026 21:54
@dee077 dee077 changed the title [feature] Django admin view for Batch command model [feature] Django admin view for Mass Command model Jul 14, 2026
@dee077
dee077 force-pushed the feature/1344-mass-command-execution-pipeline branch 5 times, most recently from ac14b28 to 8efe276 Compare July 15, 2026 23:49
@dee077
dee077 force-pushed the feature/1344-mass-command-execution-pipeline branch from 1e4e4ee to 4994e34 Compare July 16, 2026 22:03
@nemesifier

nemesifier commented Jul 22, 2026

Copy link
Copy Markdown
Member

This PR implements real-time monitoring with polling. Is polling the intended final approach? #1344 includes a Mass Command WebSocket endpoint as a requirement, although it leaves the scope open to move or split. This is confusing. Please clarify. Let's implement this asap.

Base automatically changed from feature/1344-mass-command-execution-pipeline to gsoc26-mass-commands July 22, 2026 00:54
@dee077
dee077 force-pushed the gsoc26-mass-commands branch from 2c48a5e to 0249d6a Compare July 23, 2026 09:55
dee077 added 6 commits July 23, 2026 15:25
Introduced AbstractBatchCommand model with
calculate_and_update_status() and launch()
methods to support batch command execution on
multiple devices, following the pattern of
BatchUpgradeOperation in openwisp-firmware-upgrader.

Added batch_command FK to the existing Command
model to link individual commands to their parent
batch.

Closes #1344
…nd execution

- Removed counter DB fields
- Added computed properties via aggregation
- Added execute_all boolean field
- Renamed launch() to create_commands()
- Added execute() and dry_run() classmethods
- Updated calculate_and_update_status()
- Made organization FK nullable
- Updated views with execute/dry_run
- Updated serializer with execute_all and type/input aliases
- Updated migration and celery task
…dempotency guard

- Added full_clean() to dry_run() for model-level validation
- Create failed Command records instead of skipping on validation error
- Added idempotency guard to create_commands() via Command existence check
- Narrowed ObjectDoesNotExist handler in launch_batch_command task
- Return full message_dict instead of first message on ValidationError
- Fixed migration swappable dependency for config/geo apps
- Log only field names (not values) in create_commands error handler
- Added batch_command field to expected websocket response
- Added sample_connection BatchCommand model, migration, view, and settings
- Updated geo test query count assertions
…o true

- Make type optional on GET requests via serializer __init__
- Skip full_clean() in dry_run when command_type is not provided
- Default execute_all to True for both GET and POST
dee077 and others added 23 commits July 23, 2026 15:25
- Renamed BatchCommand fields across model, serializer, migrations, and tests
- Moved test fixtures from setUp into individual test methods
- _create_batch_command now requires organization as positional arg
- Added test_batch_command_execute_queries with assertNumQueries(13)
- Added test_batch_command_cross_org_restrictions for org-level
  command restrictions
- Added device ID assertions in execute tests
- Renamed tests: list_filter_org→list_organization_scoped,
  execute_no_devices→execute_org_has_no_devices
…ommand tests

-  Added skipped_devices JSONField to track devices skipped during batch
  command creation, along with API, model, and task-level tests.
- Added skipped_devices JSONField to AbstractBatchCommand model
- Added API tests: execute, dry-run, skipped devices, org mismatch,
  authorization, query counts, device targeting by group/location
- Added model tests: str, total_devices/successful/failed, validation,
  create_commands (deactivated device, no credentials), resolve_devices,
  dry_run, execute, org mismatch, idempotency, status calculation,
  permissions
- Added task tests: deleted batch resilience, single device command
  creation, multiple device command creation
1. Passwords must not be stored.
2. Shared objects can be seen by org managers but shall not leak
   sensitive data of other tenants
…al-time monitoring #1345

- Custom admin change form with filtered/paginated commands table
- Merged skipped device rows into main commands table
- Colored status using CSS variables
- Real-time polling for in-progress batches
- Custom CSS and JS for batch command admin

Fixes #1345
…admin link

- Add  cached_property on AbstractBatchCommand (excludes skipped)
- Use  in changelist list_display for consistent status colors
- Replace ID with label as the clickable link in admin changelist
- Add  CSS to command-inline.css for consistency
- Add label, notes to change form fields; reorder columns (created last, affected_devices before created)
@dee077
dee077 force-pushed the feature/1345-mass-command-admin-workflow branch from b4dbb98 to b597697 Compare July 23, 2026 15:56
@openwisp-companion

Copy link
Copy Markdown

Code Style and QA Failures

Hello @dee077,
(Analysis for commit b597697)

The CI failed due to code style and quality issues detected by isort and flake8.

  • isort failure: Imports are incorrectly sorted or formatted.
  • flake8 failures:
  • F401 'json' imported but unused in openwisp_controller/connection/admin.py.
  • F811 redefinition of unused 'status' from line 6 in openwisp_controller/connection/api/views.py.

To fix these issues, please run the following command in your local environment:

openwisp-qa-format

This command will automatically format your code and sort imports according to the project's standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement gsoc Part of a Google Summer of Code project

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants