openwisp-radius icon indicating copy to clipboard operation
openwisp-radius copied to clipboard

[admin/api] Make batch user creation organization field readonly #609

Open Eeshu-Yadav opened this issue 4 months ago • 3 comments

Description

This PR makes the organization field readonly for existing RadiusBatch objects in both the admin interface and REST API, addressing issue #609.

When the batch user creation object has been created, there's no point in changing the organization field, and this change disallows modification to maintain data integrity.

Changes

Admin Interface

  • Modified RadiusBatchAdmin.get_readonly_fields() to include organization field for existing objects
  • Organization field remains editable when creating new RadiusBatch objects
  • Added comprehensive tests to verify readonly behavior

REST API

  • Created RadiusBatchUpdateSerializer with organization as readonly field
  • Added BatchUpdateView for handling batch detail operations (retrieve/update)
  • Added URL pattern for batch detail endpoint (/radius/batch/<uuid:pk>/)
  • Added API tests to verify organization field cannot be modified via API

Testing

  • [x] Admin tests: test_radiusbatch_organization_readonly_for_existing_objects
  • [x] Admin tests: test_radiusbatch_organization_editable_for_new_objects
  • [x] API tests: test_batch_update_organization_readonly
  • [x] API tests: test_batch_retrieve_and_update_api
  • [x] API tests: test_batch_update_permissions

Checklist

  • [x] The code follows the project's coding standards
  • [x] Tests have been added/updated to cover the changes
  • [x] All tests are passing
  • [x] The change addresses the issue requirements
  • [x] Backward compatibility is maintained (organization field still editable for new objects)

Fixes #609

Eeshu-Yadav avatar Aug 10 '25 05:08 Eeshu-Yadav

@pandafy kindly review this

Eeshu-Yadav avatar Aug 22 '25 18:08 Eeshu-Yadav

@Eeshu-Yadav what's the point of reviewing if you don't follow up?

Please follow up with https://github.com/openwisp/openwisp-radius/pull/621.

nemesifier avatar Aug 22 '25 19:08 nemesifier

@Eeshu-Yadav what's the point of reviewing if you don't follow up?

Please follow up with #621.

ok

Eeshu-Yadav avatar Aug 22 '25 21:08 Eeshu-Yadav