openwisp-controller
openwisp-controller copied to clipboard
[feature] Add API endpoint for indoor map coordinates #828
Implemented API to return device coordinates for a given location ID.
Fixes #828
Checklist
- [x] I have read the OpenWISP Contributing Guidelines.
- [x] I have manually tested the changes proposed in this pull request.
- [x] 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 #828
Description of Changes
- Added endpoint
floorplan_coordinates_listto list coordinates - Created a new serializer to add this below fields
fields = [
"name",
"mac_address",
"is_deactivated",
"model",
"os",
"floor_name",
"floor",
"image",
"location",
]
- Added filter by floor
- Added pagination class
- Added test
coverage: 98.888% (-0.01%) from 98.899% when pulling 1754156382d57116d6e482cb346b8f405d2d4d27 on dee077:feature/828-api-indoor-map-coordinates into 129a42f957166fe6652e5181e9bf03eadc2c3984 on openwisp:master.
@dee077 Isn't this part of the GSoC project idea for the indoor map?
Yes, this aligns with the GSoC project idea for the indoor map. However, at the time, it didn’t have the gsoc-idea label, so I wasn’t aware that it would be proposed as a GSoC idea for 2025.
Updates
-
Created a new filter class,
IndoorCoordinatesFilter, and overrode the get_filterset method to apply the logic for selecting the least positive floor while still allowing the organization filter to work as expected. -
Updated the serializer to include the device admin url.
-
Added docs
-
Added tests covering all scenarios except the one where an Organization Admin does not have permission to access this endpoint. I initially understood this to be equivalent to the case where the admin belongs to a different organization, which is already covered in a separate test.
Can you please explain which case the organization will not have permission to access the endpoint?
Can you please explain which case the organization will not have permission to access the endpoint?
I meant to test the scenario where the Organization Admin will not have view permission for the Location model. You can create a organization user with is_admin set to True, but don't add this user to the Administrator group.
Updates
- Added the subtest cases as mentioned above.
- Added
FilterbyParentclass on the view.
Updates
- Updated filter class as suggested.
- Updated docs
- Updated tests to use more descriptive variable names