From 2b3bbe76c20f384b5009eafdbb1b5ad4342dc42a Mon Sep 17 00:00:00 2001 From: Marcos Date: Wed, 28 Aug 2024 11:55:25 -0300 Subject: [PATCH] feat: Adding IDV Status to VerifiedName --- edx_name_affirmation/serializers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/edx_name_affirmation/serializers.py b/edx_name_affirmation/serializers.py index b67bc88..82529fb 100644 --- a/edx_name_affirmation/serializers.py +++ b/edx_name_affirmation/serializers.py @@ -19,9 +19,25 @@ class VerifiedNameSerializer(serializers.ModelSerializer): verified_name = serializers.CharField(required=True) profile_name = serializers.CharField(required=True) verification_attempt_id = serializers.IntegerField(required=False, allow_null=True) + verification_attempt_status = serializers.SerializerMethodField('get_verification_attempt_status') proctored_exam_attempt_id = serializers.IntegerField(required=False, allow_null=True) status = serializers.CharField(required=False, allow_null=True) + def get_verification_attempt_status(self, obj): + try: + from lms.djangoapps.verify_student.services import IDVerificationService + except: + return None + + idv_attempt_id = obj.verification_attempt_id + + if (not idv_attempt_id): return None + + verification = IDVerificationService.get_verification_details_by_id(idv_attempt_id) + + return verification.status if verification else "not_found" + + class Meta: """ Meta Class @@ -30,7 +46,7 @@ class Meta: fields = ( "id", "created", "username", "verified_name", "profile_name", "verification_attempt_id", - "proctored_exam_attempt_id", "status" + "verification_attempt_status", "proctored_exam_attempt_id", "status" ) def validate_verified_name(self, verified_name):