Beispiel #1
0
    def put(self, request, graph_slug, type_slug, format=None):
        """
        Change all fields at once. Omitted ones are removed
        """
        graph = get_object_or_404(Graph, slug=graph_slug)
        self.check_object_permissions(self.request, graph)

        # We get the data from the request
        post_data = request.data

        post_data['name'] = request.data.get('name', "")
        post_data['description'] = request.data.get('description', "")

        # We get the serializer of the graph to get the fields
        nodetype = get_object_or_404(NodeType,
                                     slug=type_slug,
                                     schema__graph__slug=graph_slug)
        serializer = NodeTypeSchemaSerializer(nodetype)

        serializer = NodeTypeSchemaSerializer(nodetype, data=post_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)
Beispiel #2
0
    def put(self, request, graph_slug, type_slug, format=None):
        """
        Change all fields at once. Omitted ones are removed
        """
        graph = get_object_or_404(Graph, slug=graph_slug)
        self.check_object_permissions(self.request, graph)

        # We get the data from the request
        post_data = request.data

        post_data['name'] = request.data.get('name', "")
        post_data['description'] = request.data.get('description', "")

        # We get the serializer of the graph to get the fields
        nodetype = get_object_or_404(NodeType,
                                     slug=type_slug,
                                     schema__graph__slug=graph_slug)
        serializer = NodeTypeSchemaSerializer(nodetype)

        serializer = NodeTypeSchemaSerializer(nodetype, data=post_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)
Beispiel #3
0
    def patch(self, request, graph_slug, type_slug, format=None):
        """
        Change all fields at once. Omitted ones are not modified.
        """
        graph = get_object_or_404(Graph, slug=graph_slug)
        self.check_object_permissions(self.request, graph)

        # We get the data from the request
        post_data = request.data

        nodetype = get_object_or_404(NodeType,
                                     slug=type_slug,
                                     schema__graph__slug=graph_slug)

        serializer = NodeTypeSchemaSerializer(nodetype, data=post_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)
Beispiel #4
0
    def patch(self, request, graph_slug, type_slug, format=None):
        """
        Change all fields at once. Omitted ones are not modified.
        """
        graph = get_object_or_404(Graph, slug=graph_slug)
        self.check_object_permissions(self.request, graph)

        # We get the data from the request
        post_data = request.data

        nodetype = get_object_or_404(NodeType,
                                     slug=type_slug,
                                     schema__graph__slug=graph_slug)

        serializer = NodeTypeSchemaSerializer(nodetype, data=post_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)