From a0627f921898a346bfe95579e0b3768c0d21a172 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 8 Apr 2021 09:56:55 +0900 Subject: [PATCH] Add task status api --- app/api/views/task.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/app/api/views/task.py b/app/api/views/task.py index fdc438b5..b6ed2bed 100644 --- a/app/api/views/task.py +++ b/app/api/views/task.py @@ -1,12 +1,11 @@ from celery.result import AsyncResult -from rest_framework.permissions import AllowAny, IsAuthenticated +from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView class TaskStatus(APIView): - # permission_classes = (IsAuthenticated,) - permission_classes = (AllowAny,) + permission_classes = (IsAuthenticated,) def get(self, request, *args, **kwargs): task = AsyncResult(kwargs['task_id']) @@ -18,13 +17,3 @@ class TaskStatus(APIView): 'result': task.result if ready and not error else None, 'error': {'text': str(task.result)} if error else None, }) - - -class TaskTest(APIView): - permission_classes = (AllowAny,) - - def get(self, request, *args, **kwargs): - from .. import tasks - upload_id = request.GET.get('upload_id') - task = tasks.parse.delay(upload_id) - return Response({'task_id': task.task_id})