diff --git a/cms/djangoapps/contentstore/rest_api/v1/serializers/certificates.py b/cms/djangoapps/contentstore/rest_api/v1/serializers/certificates.py index 04d028e2417..9e536efa455 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/serializers/certificates.py +++ b/cms/djangoapps/contentstore/rest_api/v1/serializers/certificates.py @@ -47,3 +47,6 @@ class CourseCertificatesSerializer(serializers.Serializer): mfe_proctored_exam_settings_url = serializers.CharField( required=False, allow_null=True, allow_blank=True ) + course_number = serializers.CharField(source="context_course.number") + course_title = serializers.CharField(source="context_course.display_name_with_default") + course_number_override = serializers.CharField(source="context_course.display_coursenumber") diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/certificates.py b/cms/djangoapps/contentstore/rest_api/v1/views/certificates.py index e338786d9c8..db93d65da68 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/certificates.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/certificates.py @@ -58,35 +58,38 @@ def get(self, request: Request, course_id: str): ```json { - "certificate_activation_handler_url": "/certificates/activation/course-v1:org+101+101/", - "certificate_web_view_url": "///certificates/course/course-v1:org+101+101?preview=honor", - "certificates": [ - { - "course_title": "Course title", - "description": "Description of the certificate", - "editing": false, - "id": 1622146085, - "is_active": false, - "name": "Name of the certificate", - "signatories": [ + "certificate_activation_handler_url": "/certificates/activation/course-v1:org+101+101/", + "certificate_web_view_url": "///certificates/course/course-v1:org+101+101?preview=honor", + "certificates": [ { - "id": 268550145, - "name": "name_sign", - "organization": "org", - "signature_image_path": "/asset-v1:org+101+101+type@asset+block@camera.png", - "title": "title_sign" - } - ], - "version": 1 - } - ], - "course_modes": [ - "honor" - ], - "has_certificate_modes": true, - "is_active": false, - "is_global_staff": true, - "mfe_proctored_exam_settings_url": "" + "course_title": "Course title", + "description": "Description of the certificate", + "editing": false, + "id": 1622146085, + "is_active": false, + "name": "Name of the certificate", + "signatories": [ + { + "id": 268550145, + "name": "name_sign", + "organization": "org", + "signature_image_path": "/asset-v1:org+101+101+type@asset+block@camera.png", + "title": "title_sign" + } + ], + "version": 1 + }, + ], + "course_modes": [ + "honor" + ], + "has_certificate_modes": true, + "is_active": false, + "is_global_staff": true, + "mfe_proctored_exam_settings_url": "", + "course_number": "DemoX", + "course_title": "Demonstration Course", + "course_number_override": "Course Number Display String" } ``` """ diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_certificates.py b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_certificates.py index e63cda981ac..db9d1dacca9 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_certificates.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_certificates.py @@ -28,7 +28,11 @@ def test_success_response(self): """ self._add_course_certificates(count=2, signatory_count=2) response = self.client.get(self.url) + response_data = response.data self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data["certificates"]), 2) - self.assertEqual(len(response.data["certificates"][0]["signatories"]), 2) - self.assertEqual(len(response.data["certificates"][1]["signatories"]), 2) + self.assertEqual(len(response_data["certificates"]), 2) + self.assertEqual(len(response_data["certificates"][0]["signatories"]), 2) + self.assertEqual(len(response_data["certificates"][1]["signatories"]), 2) + self.assertEqual(response_data["course_number_override"], self.course.display_coursenumber) + self.assertEqual(response_data["course_title"], self.course.display_name_with_default) + self.assertEqual(response_data["course_number"], self.course.number)