openwisp / django-rest-framework-gis

Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.
http://openwisp.org
MIT License
1.07k stars 200 forks source link

[feat] add support for `dist` parameter on `DistanceToPointOrderingFilter` #274

Open carolinekessler opened 2 years ago

carolinekessler commented 2 years ago

The DistanceToPointOrderingFilter inherits from the DistanceToPointFilter but only supports the point param and no dist param. This adds support for the dist param (such that a user can query for all points within a certain dist of the given point and have the results returned in asc or desc order) by combining the filter_queryset logic of the existing DistanceToPointOrderingFilter#filter_queryset and the DistanceToPointFilter#filter_queryset.

This also implements a get_schema_fields() method so the filter fields can be included in schema autogeneration provided by the Django REST framework (documentation linked)