Updates the post view to return the async task id. Adds query parameter to the tasks endpoint to get single task status

This commit is contained in:
Trenton Holmes 2022-12-30 13:43:49 -08:00
parent a83058ab11
commit 50c0c65c60

View File

@ -617,7 +617,7 @@ class PostDocumentView(GenericAPIView):
task_id = str(uuid.uuid4()) task_id = str(uuid.uuid4())
consume_file.delay( async_task = consume_file.delay(
temp_filename, temp_filename,
override_filename=doc_name, override_filename=doc_name,
override_title=title, override_title=title,
@ -628,7 +628,7 @@ class PostDocumentView(GenericAPIView):
override_created=created, override_created=created,
) )
return Response("OK") return Response(async_task.id)
class SelectionDataView(GenericAPIView): class SelectionDataView(GenericAPIView):
@ -886,6 +886,7 @@ class TasksViewSet(ReadOnlyModelViewSet):
permission_classes = (IsAuthenticated,) permission_classes = (IsAuthenticated,)
serializer_class = TasksViewSerializer serializer_class = TasksViewSerializer
def get_queryset(self):
queryset = ( queryset = (
PaperlessTask.objects.filter( PaperlessTask.objects.filter(
acknowledged=False, acknowledged=False,
@ -893,6 +894,10 @@ class TasksViewSet(ReadOnlyModelViewSet):
.order_by("date_created") .order_by("date_created")
.reverse() .reverse()
) )
task_id = self.request.query_params.get("task_id")
if task_id is not None:
queryset = PaperlessTask.objects.filter(task_id=task_id)
return queryset
class AcknowledgeTasksView(GenericAPIView): class AcknowledgeTasksView(GenericAPIView):