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})
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})
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)
def list(self, request): broken_references = Reference.find_broken_references() serializer = serializers.ReferenceListSerializer( instance=broken_references) return Response(serializer.data)