Skip to content

Commit

Permalink
feat!: upgrading api to DRF.
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 committed Sep 24, 2024
1 parent 67bde49 commit ee6045c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lms/djangoapps/instructor/tests/test_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ee6045c

Please sign in to comment.