diff --git a/sensorsafrica/api/v1/serializers.py b/sensorsafrica/api/v1/serializers.py index 1aba22d..bf1b951 100644 --- a/sensorsafrica/api/v1/serializers.py +++ b/sensorsafrica/api/v1/serializers.py @@ -10,10 +10,13 @@ NestedSensorSerializer, SensorDataSerializer as PostSensorDataSerializer ) +class NodeLocationSerializer(NestedSensorLocationSerializer): + class Meta(NestedSensorLocationSerializer.Meta): + fields = NestedSensorLocationSerializer.Meta.fields + ("latitude", "longitude", "city") class NodeSerializer(serializers.ModelSerializer): sensors = NestedSensorSerializer(many=True) - location = NestedSensorLocationSerializer() + location = NodeLocationSerializer() class Meta: model = Node diff --git a/sensorsafrica/api/v2/filters.py b/sensorsafrica/api/v2/filters.py index b6b6e91..92d6f61 100644 --- a/sensorsafrica/api/v2/filters.py +++ b/sensorsafrica/api/v2/filters.py @@ -1,15 +1,6 @@ -from django.db import models -import django_filters from feinstaub.sensors.views import SensorFilter class CustomSensorFilter(SensorFilter): class Meta(SensorFilter.Meta): - fields = {"sensor": ["exact"], - "location__country": ['exact'], - "timestamp": ("gte", "lte"), - } - filter_overrides = { - models.DateTimeField: { - 'filter_class': django_filters.IsoDateTimeFilter, - }, - } + # Pick the fields already defined and add the location__country field + fields = {**SensorFilter.Meta.fields, **{'location__country': ['exact']}}