From ee6045cb42ab34115daabaa90cdf02953e5930ed Mon Sep 17 00:00:00 2001 From: awais qureshi Date: Tue, 24 Sep 2024 16:33:38 +0500 Subject: [PATCH] feat!: upgrading api to DRF. --- lms/djangoapps/instructor/tests/test_certificates.py | 4 ++-- lms/djangoapps/instructor/views/api.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/instructor/tests/test_certificates.py b/lms/djangoapps/instructor/tests/test_certificates.py index 5aa2be766759..88d991be9af0 100644 --- a/lms/djangoapps/instructor/tests/test_certificates.py +++ b/lms/djangoapps/instructor/tests/test_certificates.py @@ -1105,7 +1105,7 @@ def test_invalid_user_name_error(self): assert response.status_code == 400 res_json = json.loads(response.content.decode('utf-8')) # Assert Error Message - assert res_json['errors'] == ('test_invalid_user_name does not exist in the LMS. ' + assert res_json['message'] == ('test_invalid_user_name does not exist in the LMS. ' 'Please check your spelling and retry.') def test_no_generated_certificate_error(self): @@ -1124,7 +1124,7 @@ def test_no_generated_certificate_error(self): assert response.status_code == 400 res_json = json.loads(response.content.decode('utf-8')) # Assert Error Message - assert res_json['errors'] == f'The student {self.enrolled_user_2.username} does not have certificate for the course {self.course.number}. Kindly verify student username/email and the selected course are correct and try again.' # pylint: disable=line-too-long + assert res_json['message'] == f'The student {self.enrolled_user_2.username} does not have certificate for the course {self.course.number}. Kindly verify student username/email and the selected course are correct and try again.' # pylint: disable=line-too-long def test_certificate_already_invalid_error(self): """ diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 7678a0a47126..2bc88637443f 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -3649,12 +3649,12 @@ def post(self, request, course_id): invalid_user = request.data.get('user') response_payload = f'{invalid_user} does not exist in the LMS. Please check your spelling and retry.' - return JsonResponse({'errors': response_payload}, status=400) + return JsonResponse({'message': response_payload}, status=400) try: certificate = _get_certificate_for_user(course_key, student) except Exception as ex: - return JsonResponse({'errors': str(ex)}, status=400) + return JsonResponse({'message': str(ex)}, status=400) # Invalidate certificate of the given student for the course course try: