From e31b49c489bb248ac8a10869453dd3089621298a Mon Sep 17 00:00:00 2001 From: awais qureshi Date: Thu, 22 Aug 2024 19:40:04 +0500 Subject: [PATCH 1/2] feat: upgrading simple api to drf compatible. --- lms/djangoapps/instructor/views/api.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 7ca1e70467b0..afb14a446e63 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -2516,14 +2516,22 @@ def get(self, request, course_id): @require_POST @ensure_csrf_cookie -def list_report_downloads(request, course_id): +@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True), name='dispatch') +class ListReportDownloads(APIView): + """ List grade CSV files that are available for download for this course. Takes the following query parameters: - (optional) report_name - name of the report """ - return _list_report_downloads(request=request, course_id=course_id) + permission_classes = (IsAuthenticated, permissions.InstructorPermission) + permission_name = permissions.CAN_RESEARCH + + @method_decorator(ensure_csrf_cookie) + def post(self, request, course_id): + + return _list_report_downloads(request=request, course_id=course_id) @cache_control(no_cache=True, no_store=True, must_revalidate=True) From 9a531d0a0ebc8a0ad39941fecf2ef139606ddf85 Mon Sep 17 00:00:00 2001 From: awais qureshi Date: Thu, 22 Aug 2024 19:46:16 +0500 Subject: [PATCH 2/2] feat: upgrading simple api to drf compatible. --- lms/djangoapps/instructor/views/api.py | 2 -- lms/djangoapps/instructor/views/api_urls.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index afb14a446e63..8cfe36417f5c 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -2514,8 +2514,6 @@ def get(self, request, course_id): return _list_report_downloads(request=request, course_id=course_id) -@require_POST -@ensure_csrf_cookie @method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True), name='dispatch') class ListReportDownloads(APIView): diff --git a/lms/djangoapps/instructor/views/api_urls.py b/lms/djangoapps/instructor/views/api_urls.py index c0e12e46756d..0aaf1b683624 100644 --- a/lms/djangoapps/instructor/views/api_urls.py +++ b/lms/djangoapps/instructor/views/api_urls.py @@ -59,7 +59,7 @@ path('get_proctored_exam_results', api.get_proctored_exam_results, name='get_proctored_exam_results'), # Grade downloads... - path('list_report_downloads', api.list_report_downloads, name='list_report_downloads'), + path('list_report_downloads', api.ListReportDownloads.as_view(), name='list_report_downloads'), path('calculate_grades_csv', api.calculate_grades_csv, name='calculate_grades_csv'), path('problem_grade_report', api.problem_grade_report, name='problem_grade_report'),