Exemplo n.º 1
0
    def list(self, request):
        task = AsyncResult(request.GET.get('task'))

        if task.successful():
            broken_references = task.get()
            serializer = serializers.ReferenceListSerializer(
                instance=broken_references)
            return Response(serializer.data)
        elif task.failed():
            return Response({'exception': str(task.result)}, status=status.HTTP_400_BAD_REQUEST)
        else:
            return Response({'task': task.id, 'state': task.state})
Exemplo n.º 2
0
    def get(self, request):
        task = AsyncResult(request.GET.get('task'))

        if task.successful():
            broken_references = task.get()
            serializer = serializers.ReferenceListSerializer(
                instance=broken_references)
            return Response(serializer.data)
        elif task.failed():
            return Response({'exception': str(task.result)}, status=status.HTTP_400_BAD_REQUEST)
        elif task.state == 'PENDING' and not task_exists(task.id):
            return Response({'exception': 'task '+ task.id +' not found'}, status=status.HTTP_404_NOT_FOUND)
        else:
            return Response({'task': task.id, 'state': task.state})
Exemplo n.º 3
0
    def delete(self, request):
        force = request.GET.get('force')
        if not force:
            force = False
        task = AsyncResult(request.GET.get('task'))

        if task.successful():
            broken_references = task.get()

            broken_references.delete(force)

            serializer = serializers.ReferenceListSerializer(
                instance=broken_references)
            return Response(serializer.data)
        elif task.failed():
            return Response({'exception': str(task.result)}, status=status.HTTP_400_BAD_REQUEST)
        else:
            return Response({'state': task.state}, status=status.HTTP_204_NO_CONTENT)
Exemplo n.º 4
0
    def list(self, request):
        broken_references = Reference.find_broken_references()

        serializer = serializers.ReferenceListSerializer(
            instance=broken_references)
        return Response(serializer.data)