Ejemplo n.º 1
0
    def patch(self, request, pk, format=None):
        dataset = self.get_object(pk)

        d = copy(request.data)
        d['type'] = dataset.type
        serializer = DatasetSerializer(dataset, data=d)

        if dataset.type == 'wms.ugridtidedataset':
            serializer = UGridTideDatasetSerializer(dataset,
                                                    data=request.data,
                                                    partial=True)
        elif dataset.type == 'wms.ugriddataset':
            serializer = UGridDatasetSerializer(dataset,
                                                data=request.data,
                                                partial=True)
        elif dataset.type == 'wms.sgriddataset':
            serializer = SGridDatasetSerializer(dataset,
                                                data=request.data,
                                                partial=True)
        elif dataset.type == 'wms.rgriddataset':
            serializer = RGridDatasetSerializer(dataset,
                                                data=request.data,
                                                partial=True)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 2
0
 def get(self, request, format=None):
     snippets = Dataset.objects.select_related().all()
     serializer = DatasetSerializer(snippets, many=True)
     return Response(serializer.data)
Ejemplo n.º 3
0
 def get(self, request, pk, format=None):
     dataset = self.get_object(pk)
     serializer = DatasetSerializer(dataset)
     return Response(serializer.data)