Skip to content

Commit

Permalink
feat: Adding IDV Status to VerifiedName
Browse files Browse the repository at this point in the history
  • Loading branch information
rijuma committed Aug 28, 2024
1 parent d0b4a9a commit b3d80d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion edx_name_affirmation/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions edx_name_affirmation/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def test_post_200(self):
'profile_name': self.PROFILE_NAME,
'verified_name': self.VERIFIED_NAME,
'verification_attempt_id': self.ATTEMPT_ID,
'verification_attempt_status': None,
}
response = self.client.post(
reverse('edx_name_affirmation:verified_name'),
Expand Down

0 comments on commit b3d80d0

Please sign in to comment.