Exemple #1
0
    def put(self, request, pk):
        data = JSONParser().parse(request)
        document = self.get_object(pk)

        serializer = DocumentSerializer(document, data=data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemple #2
0
    def put(self, request, pk):
        data = JSONParser().parse(request)
        document = self.get_object(pk)

        if request.user.has_perm(Access.PERM_WRITE, document):
            serializer = DocumentSerializer(document, data=data)

            if serializer.is_valid():
                serializer.save()
                return Response(serializer.data)

        return Response(status=status.HTTP_403_FORBIDDEN)