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

[feature] Add API endpoint for indoor map coordinates #828

Open dee077 opened this issue 10 months ago • 3 comments

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_list to 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

dee077 avatar Feb 02 '25 13:02 dee077

Coverage Status

coverage: 98.888% (-0.01%) from 98.899% when pulling 1754156382d57116d6e482cb346b8f405d2d4d27 on dee077:feature/828-api-indoor-map-coordinates into 129a42f957166fe6652e5181e9bf03eadc2c3984 on openwisp:master.

coveralls avatar Feb 02 '25 17:02 coveralls

@dee077 Isn't this part of the GSoC project idea for the indoor map?

nemesifier avatar Feb 06 '25 22:02 nemesifier

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.

dee077 avatar Feb 07 '25 07:02 dee077

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?

dee077 avatar Jul 09 '25 23:07 dee077

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.

pandafy avatar Jul 10 '25 09:07 pandafy

Updates

  • Added the subtest cases as mentioned above.
  • Added FilterbyParent class on the view.

dee077 avatar Jul 12 '25 00:07 dee077

Updates

  • Updated filter class as suggested.
  • Updated docs
  • Updated tests to use more descriptive variable names

dee077 avatar Jul 16 '25 21:07 dee077