From 19679490d56cf213f5bcd21b6ca2336138da3d5a Mon Sep 17 00:00:00 2001 From: Dirk Uys Date: Thu, 20 Jun 2024 13:44:39 +0200 Subject: [PATCH] Add UX to poll and display link --- studygroups/views/staff.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/studygroups/views/staff.py b/studygroups/views/staff.py index cddbe44b..b2275452 100644 --- a/studygroups/views/staff.py +++ b/studygroups/views/staff.py @@ -26,6 +26,7 @@ from django.db.models import F, Case, When, Value, Sum, IntegerField from django_celery_results.models import TaskResult +from celery.result import AsyncResult from studygroups.models import Application from studygroups.models import StudyGroup @@ -80,15 +81,15 @@ def get(self, request, *args, **kwargs): @method_decorator(user_is_staff, name='dispatch') -class ExportStatusView(SingleObjectMixin, View): - model = TaskResult - pk_url_kwarg = 'task_id' +class ExportStatusView(View): def get(self, request, *args, **kwargs): - result = get_object_or_404(TaskResult, task_id= kwargs.get('task_id')) + task_id = kwargs.get('task_id') + #result = get_object_or_404(TaskResult, task_id=task_id) # TODO - check that the task was an export # TODO - return usefull data for the task - return json_response(request, {'task_id': result.task_id, 'status': result.status}) + result = AsyncResult(task_id) + return json_response(request, {'task_id': result.task_id, 'status': result.state, 'result': result.result}) @method_decorator(user_is_staff, name='dispatch')