openwisp-radius
openwisp-radius copied to clipboard
[admin/api] Make batch user creation organization field readonly #609
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 includeorganizationfield for existing objects - Organization field remains editable when creating new RadiusBatch objects
- Added comprehensive tests to verify readonly behavior
REST API
- Created
RadiusBatchUpdateSerializerwith organization as readonly field - Added
BatchUpdateViewfor 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
@pandafy kindly review this
@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.
@Eeshu-Yadav what's the point of reviewing if you don't follow up?
Please follow up with #621.
ok