From a7e712ad4ebb463a4a6e2c408d2d2eac7a57859a Mon Sep 17 00:00:00 2001 From: Dillon Dumesnil Date: Tue, 8 Dec 2020 20:08:52 +0000 Subject: [PATCH] AA-503: Add id verification status into API This will be used for the Course Exit experience to improve our messaging for learners in the 'pending' state --- openedx/core/djangoapps/courseware_api/serializers.py | 1 + .../djangoapps/courseware_api/tests/test_views.py | 2 ++ openedx/core/djangoapps/courseware_api/views.py | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/openedx/core/djangoapps/courseware_api/serializers.py b/openedx/core/djangoapps/courseware_api/serializers.py index 712cb71b85..ad449a60ae 100644 --- a/openedx/core/djangoapps/courseware_api/serializers.py +++ b/openedx/core/djangoapps/courseware_api/serializers.py @@ -112,6 +112,7 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract- course_exit_page_is_active = serializers.BooleanField() certificate_data = CertificateDataSerializer() verify_identity_url = AbsoluteURLField() + verification_status = serializers.CharField() linkedin_add_to_profile_url = serializers.URLField() def __init__(self, *args, **kwargs): diff --git a/openedx/core/djangoapps/courseware_api/tests/test_views.py b/openedx/core/djangoapps/courseware_api/tests/test_views.py index fa1a6e437d..bef80f3e18 100644 --- a/openedx/core/djangoapps/courseware_api/tests/test_views.py +++ b/openedx/core/djangoapps/courseware_api/tests/test_views.py @@ -130,12 +130,14 @@ class CourseApiTestViews(BaseCoursewareTests): 'The audit track does not include a certificate.') assert response.data['certificate_data']['msg'] == expected_audit_message assert response.data['verify_identity_url'] is None + assert response.data['verification_status'] is 'none' assert response.data['linkedin_add_to_profile_url'] is None else: assert response.data['certificate_data']['cert_status'] == 'earned_but_not_available' expected_verify_identity_url = reverse('verify_student_verify_now', args=[self.course.id]) # The response contains an absolute URL so this is only checking the path of the final assert expected_verify_identity_url in response.data['verify_identity_url'] + assert response.data['verification_status'] is 'none' request = RequestFactory().request() cert_url = get_certificate_url(course_id=self.course.id, uuid=cert.verify_uuid) diff --git a/openedx/core/djangoapps/courseware_api/views.py b/openedx/core/djangoapps/courseware_api/views.py index b7d162be13..eb7449f7e8 100644 --- a/openedx/core/djangoapps/courseware_api/views.py +++ b/openedx/core/djangoapps/courseware_api/views.py @@ -257,6 +257,17 @@ class CoursewareMeta: else: return IDVerificationService.get_verify_location('verify_student_verify_now', self.course_key) + @property + def verification_status(self): + """ + Returns a String of the verification status of learner. + """ + if self.enrollment_object and self.enrollment_object.mode in CourseMode.VERIFIED_MODES: + return IDVerificationService.user_status(self.effective_user)['status'] + # I know this looks weird (and is), but this is just so it is inline with what the + # IDVerificationService.user_status method would return before a verification was created + return 'none' + @property def linkedin_add_to_profile_url(self): """