geosolutions-it / gfdrr-det

Data Exploration Tool
https://waffle.io/geosolutions-it/gfdrr-det
GNU General Public License v3.0
3 stars 0 forks source link

Category filter disregards non-existent values #108

Closed ricardogsilva closed 6 years ago

ricardogsilva commented 6 years ago

This PR is connected to #15

It refactors the category filter of the gfdrr_det/api/v1/exposures endpoint in order to allow filtering by multiple values even if some of them are not valid. It replaces the usage of a MultipleChoiceFilter with a custom CategoryInFilter. This has two side-effects:

The implementation of the filtering was done using a custom method and django Q objects that are OR'ed together. This customization was necessary because the current version of django does not support using the in lookup field on JSONFields.

Filtering exposure layers by categories should now be done like this:

/gfdrr_det/api/v1/exposures/?category=buildings,road_network,fake_value