Ejemplo n.º 1
0
    def post(self, request, format=None):
        if 'ugrid' in request.data['type']:
            request.data['type'] = 'wms.ugriddataset'
            serializer = UGridDatasetSerializer(data=request.data)
        elif 'sgrid' in request.data['type']:
            request.data['type'] = 'wms.sgriddataset'
            serializer = SGridDatasetSerializer(data=request.data)
        elif 'rgrid' in request.data['type']:
            request.data['type'] = 'wms.rgriddataset'
            serializer = RGridDatasetSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 2
0
    def put(self, request, pk, format=None):
        dataset = self.get_object(pk)
        if 'ugrid' in request.data['type']:
            request.data['type'] = 'wms.ugriddataset'
            serializer = UGridDatasetSerializer(dataset, data=request.data)
        elif 'sgrid' in request.data['type']:
            request.data['type'] = 'wms.sgriddataset'
            serializer = SGridDatasetSerializer(dataset, data=request.data)
        elif 'rgrid' in request.data['type']:
            request.data['type'] = 'wms.rgriddataset'
            serializer = RGridDatasetSerializer(dataset, data=request.data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 3
0
    def post(self, request, format=None):
        if 'ugrid' in request.data['type']:
            request.data['type'] = 'wms.ugriddataset'
            serializer = UGridDatasetSerializer(data=request.data)
        elif 'sgrid' in request.data['type']:
            request.data['type'] = 'wms.sgriddataset'
            serializer = SGridDatasetSerializer(data=request.data)
        elif 'rgrid' in request.data['type']:
            request.data['type'] = 'wms.rgriddataset'
            serializer = RGridDatasetSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 4
0
    def put(self, request, pk, format=None):
        dataset = self.get_object(pk)
        if 'ugrid' in request.data['type']:
            request.data['type'] = 'wms.ugriddataset'
            serializer = UGridDatasetSerializer(dataset, data=request.data)
        elif 'sgrid' in request.data['type']:
            request.data['type'] = 'wms.sgriddataset'
            serializer = SGridDatasetSerializer(dataset, data=request.data)
        elif 'rgrid' in request.data['type']:
            request.data['type'] = 'wms.rgriddataset'
            serializer = RGridDatasetSerializer(dataset, data=request.data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)