from rest_framework.decorators import list_route
from rest_framework.mixins import ListModelMixin
from rest_framework.serializers import CharField
from rest_framework.viewsets import GenericViewSet
from rest_framework_gis.serializers import GeoFeatureModelSerializer
from pollingstations.models import PollingStation


class PollingStationSerializer(GeoFeatureModelSerializer):

    station_id = CharField(source='internal_council_id', read_only=True)

    class Meta:
        model = PollingStation
        geo_field = 'location'
        fields = ('council', 'station_id', 'postcode', 'address', 'location')


class PollingStationViewSet(GenericViewSet, ListModelMixin):
    queryset = PollingStation.objects.all()
    serializer_class = PollingStationSerializer

    @list_route(url_path='geo')
    def geo(self, request, format=None):
        return self.list(request, format=None)

@@ -91,16 +91,61 @@
 elMixin%0A
+from rest_framework.response import Response%0A
 from res
@@ -803,16 +803,896 @@
 alizer%0A%0A
+    def get_queryset(self):%0A        council_id = self.request.query_params.get('council_id', None)%0A        station_id = self.request.query_params.get('station_id', None)%0A%0A        if council_id is None:%0A            return PollingStation.objects.all()%0A%0A        if station_id is None:%0A            return PollingStation.objects.filter(council=council_id)%0A%0A        return PollingStation.objects.filter(%0A            council=council_id, internal_council_id=station_id)%0A%0A    def list(self, request, *args, **kwargs):%0A        if 'station_id' in request.query_params and%5C%0A            'council_id' not in request.query_params:%0A            return Response(%0A                %7B'detail': 'council_id parameter must be specified'%7D, 400)%0A%0A        queryset = self.get_queryset()%0A        serializer = self.get_serializer(queryset, many=True, read_only=True)%0A        return Response(serializer.data)%0A%0A
     @lis

add filters to /pollingstations endpoint