Ejemplo n.º 1
0
    def post(self, request):
        """
        Creates a new Allocation
        """
        data = request.DATA
        serializer = AllocationSerializer(data=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 post(self, request):
        """
        Creates a new Allocation
        """
        data = request.data
        serializer = AllocationSerializer(data=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.º 3
0
    def patch(self, request, quota_id):
        """
        Partially updates the specified Allocation
        """
        data = request.DATA
        allocation = get_object_or_404(Allocation, id=quota_id)
        serializer = AllocationSerializer(allocation, data=data, partial=True)

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

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 4
0
    def patch(self, request, quota_id):
        """
        Partially updates the specified Allocation
        """
        data = request.data
        allocation = get_object_or_404(Allocation, id=quota_id)
        serializer = AllocationSerializer(allocation, data=data, partial=True)

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

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)