@@ -2742,22 +2742,35 @@ def post(self, request, course_id):
27422742 return JsonResponse ({"error" : str (err )}, status = 400 )
27432743
27442744
2745- @transaction .non_atomic_requests
2746- @require_POST
2747- @ensure_csrf_cookie
2748- @cache_control (no_cache = True , no_store = True , must_revalidate = True )
2749- @require_course_permission (permissions .CAN_RESEARCH )
2750- @common_exceptions_400
2751- def export_ora2_summary (request , course_id ):
2745+ @method_decorator (transaction .non_atomic_requests , name = 'dispatch' )
2746+ class ExportOra2SummaryView (DeveloperErrorViewMixin , APIView ):
27522747 """
2753- Pushes a Celery task which will aggregate a summary students' progress in ora2 tasks for a course into a .csv
2748+ Pushes a Celery task which will aggregate a summary of students' progress in ora2 tasks for a course into a .csv
27542749 """
2755- course_key = CourseKey .from_string (course_id )
2756- report_type = _ ('ORA summary' )
2757- task_api .submit_export_ora2_summary (request , course_key )
2758- success_status = SUCCESS_MESSAGE_TEMPLATE .format (report_type = report_type )
2750+ permission_classes = (IsAuthenticated , permissions .InstructorPermission )
2751+ permission_name = permissions .CAN_RESEARCH
27592752
2760- return JsonResponse ({"status" : success_status })
2753+ @method_decorator (ensure_csrf_cookie )
2754+ @method_decorator (cache_control (no_cache = True , no_store = True , must_revalidate = True ))
2755+ def post (self , request , course_id ):
2756+ """
2757+ Initiates a Celery task to generate an ORA summary report for the specified course.
2758+
2759+ Args:
2760+ request: The HTTP request object
2761+ course_id: The string representation of the course key
2762+
2763+ Returns:
2764+ Response: A JSON response with a status message indicating the report generation has started
2765+ """
2766+ course_key = CourseKey .from_string (course_id )
2767+ report_type = _ ('ORA summary' )
2768+ try :
2769+ task_api .submit_export_ora2_summary (request , course_key )
2770+ success_status = SUCCESS_MESSAGE_TEMPLATE .format (report_type = report_type )
2771+ return Response ({"status" : success_status })
2772+ except (AlreadyRunningError , QueueConnectionError , AttributeError ) as err :
2773+ return JsonResponse ({"error" : str (err )}, status = 400 )
27612774
27622775
27632776@transaction .non_atomic_requests
0 commit comments