Exemplo n.º 1
0
    def patch(self, request, provider_id, identity_id, machine_export_id):
        """
        Meta data changes in 'pending' are OK
        Status change 'pending' --> 'cancel' are OK
        All other changes should FAIL
        """
        #user = request.user
        data = request.DATA
        try:
            mach_request = CoreMachineExport.objects.get(id=machine_export_id)
        except CoreMachineExport.DoesNotExist:
            return Response(
                'No machine request with id %s' % machine_export_id,
                status=status.HTTP_404_NOT_FOUND)

        serializer = MachineExportSerializer(mach_request,
                                             data=data, partial=True)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 2
0
    def patch(self, request, provider_id, identity_id, machine_export_id):
        """
        Meta data changes in 'pending' are OK
        Status change 'pending' --> 'cancel' are OK
        All other changes should FAIL
        """
        #user = request.user
        data = request.DATA
        try:
            mach_request = CoreMachineExport.objects.get(id=machine_export_id)
        except CoreMachineExport.DoesNotExist:
            return Response('No machine request with id %s' %
                            machine_export_id,
                            status=status.HTTP_404_NOT_FOUND)

        serializer = MachineExportSerializer(mach_request,
                                             data=data,
                                             partial=True)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 3
0
 def post(self, request, provider_id, identity_id):
     """
     Create a new object based on DATA
     Start the MachineExportThread if not running
         & Add all images marked 'queued'
     OR
     Add self to MachineExportQueue
     Return to user with "queued"
     """
     #request.DATA is r/o
     data = copy.deepcopy(request.DATA)
     owner = request.user.username
     #Staff members can export on users behalf..
     if data.get('created_for') and request.user.is_staff:
         owner = data.get('created_for')
     data['owner'] = owner
     logger.info(data)
     serializer = MachineExportSerializer(data=data)
     if serializer.is_valid():
         export_request = serializer.save()
         machine_export_task.delay(export_request)
     return Response(serializer.data, status=status.HTTP_200_OK)
Exemplo n.º 4
0
 def post(self, request, provider_id, identity_id):
     """
     Create a new object based on DATA
     Start the MachineExportThread if not running
         & Add all images marked 'queued'
     OR
     Add self to MachineExportQueue
     Return to user with "queued"
     """
     #request.DATA is r/o
     data = copy.deepcopy(request.DATA)
     owner = request.user.username
     #Staff members can export on users behalf..
     if data.get('created_for') and request.user.is_staff:
         owner = data.get('created_for')
     data['owner'] = owner
     logger.info(data)
     serializer = MachineExportSerializer(data=data)
     if serializer.is_valid():
         export_request = serializer.save()
         machine_export_task.delay(export_request)
     return Response(serializer.data, status=status.HTTP_200_OK)