feat: export ora2 submission files to DRF (#36557)
* feat: export ora2 submission files to DRF
This commit is contained in:
@@ -2773,26 +2773,30 @@ class ExportOra2SummaryView(DeveloperErrorViewMixin, APIView):
|
||||
return JsonResponse({"error": str(err)}, status=400)
|
||||
|
||||
|
||||
@transaction.non_atomic_requests
|
||||
@require_POST
|
||||
@ensure_csrf_cookie
|
||||
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
|
||||
@require_course_permission(permissions.CAN_RESEARCH)
|
||||
@common_exceptions_400
|
||||
def export_ora2_submission_files(request, course_id):
|
||||
@method_decorator(transaction.non_atomic_requests, name='dispatch')
|
||||
class ExportOra2SubmissionFilesView(DeveloperErrorViewMixin, APIView):
|
||||
"""
|
||||
Pushes a Celery task which will download and compress all submission
|
||||
files (texts, attachments) into a zip archive.
|
||||
"""
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
permission_classes = (IsAuthenticated, permissions.InstructorPermission)
|
||||
permission_name = permissions.CAN_RESEARCH
|
||||
|
||||
task_api.submit_export_ora2_submission_files(request, course_key)
|
||||
|
||||
return JsonResponse({
|
||||
"status": _(
|
||||
"Attachments archive is being created."
|
||||
)
|
||||
})
|
||||
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True))
|
||||
@method_decorator(ensure_csrf_cookie)
|
||||
def post(self, request, course_id):
|
||||
"""
|
||||
Initiates a task to export all ORA2 submission files for a course.
|
||||
Returns a JSON response indicating the export task has been started.
|
||||
"""
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
try:
|
||||
task_api.submit_export_ora2_submission_files(request, course_key)
|
||||
return Response({
|
||||
"status": _("Attachments archive is being created.")
|
||||
})
|
||||
except (AlreadyRunningError, QueueConnectionError, AttributeError) as err:
|
||||
return JsonResponse({"error": str(err)}, status=400)
|
||||
|
||||
|
||||
@method_decorator(transaction.non_atomic_requests, name='dispatch')
|
||||
|
||||
@@ -69,7 +69,7 @@ urlpatterns = [
|
||||
path('export_ora2_data', api.ExportOra2DataView.as_view(), name='export_ora2_data'),
|
||||
path('export_ora2_summary', api.ExportOra2SummaryView.as_view(), name='export_ora2_summary'),
|
||||
|
||||
path('export_ora2_submission_files', api.export_ora2_submission_files,
|
||||
path('export_ora2_submission_files', api.ExportOra2SubmissionFilesView.as_view(),
|
||||
name='export_ora2_submission_files'),
|
||||
|
||||
# spoc gradebook
|
||||
|
||||
Reference in New Issue
Block a user