diff --git a/lms/djangoapps/certificates/generation_handler.py b/lms/djangoapps/certificates/generation_handler.py index 9ea31d9beb92411e6956986bef37edf86d6a4a2e..137bb974081081702deeb929f14e8c8e1751dc1e 100644 --- a/lms/djangoapps/certificates/generation_handler.py +++ b/lms/djangoapps/certificates/generation_handler.py @@ -102,8 +102,8 @@ def can_generate_allowlist_certificate(user, course_key): )) return False - if not IDVerificationService.user_has_ever_been_verified(user): - log.info(f'{user.id} has not ever had a verified id. Certificate cannot be generated.') + if not IDVerificationService.user_is_verified(user): + log.info(f'{user.id} does not have a verified id. Certificate cannot be generated.') return False if not _is_on_certificate_allowlist(user, course_key): diff --git a/lms/djangoapps/certificates/tests/test_generation_handler.py b/lms/djangoapps/certificates/tests/test_generation_handler.py index 14b6d11f6b4f12983f1baf2b9f6fb33e395c70fc..a5b8cf06b11e0cf174700260f00e876dd89af3fd 100644 --- a/lms/djangoapps/certificates/tests/test_generation_handler.py +++ b/lms/djangoapps/certificates/tests/test_generation_handler.py @@ -31,7 +31,7 @@ from openedx.core.djangoapps.certificates.config import waffle log = logging.getLogger(__name__) -ID_VERIFIED_METHOD = 'lms.djangoapps.verify_student.services.IDVerificationService.user_has_ever_been_verified' +ID_VERIFIED_METHOD = 'lms.djangoapps.verify_student.services.IDVerificationService.user_is_verified' AUTO_GENERATION_NAMESPACE = waffle.WAFFLE_NAMESPACE AUTO_GENERATION_NAME = waffle.AUTO_CERTIFICATE_GENERATION AUTO_GENERATION_SWITCH_NAME = '{}.{}'.format(AUTO_GENERATION_NAMESPACE, AUTO_GENERATION_NAME) diff --git a/lms/djangoapps/verify_student/services.py b/lms/djangoapps/verify_student/services.py index 31438cc93d638aad26172ff5884af49c7653b57c..b16bfd7c44a1baeb815084236553aabe6dad11bd 100644 --- a/lms/djangoapps/verify_student/services.py +++ b/lms/djangoapps/verify_student/services.py @@ -69,31 +69,6 @@ class IDVerificationService: return expiration_datetime >= now() return False - @classmethod - def user_has_ever_been_verified(cls, user): - """ - Return whether or not a user has ever satisfactorily proved their identity (has had an approved verification) - of any kind. - """ - if not user: - log.warning('No user provided. Verification attempts cannot be checked.') - return False - - if SoftwareSecurePhotoVerification.objects.filter(user=user, status='approved').exists(): - log.info(f'User {user.id} has an approved SoftwareSecurePhotoVerification') - return True - - if SSOVerification.objects.filter(user=user, status='approved').exists(): - log.info(f'User {user.id} has an approved SSOVerification') - return True - - if ManualVerification.objects.filter(user=user, status='approved').exists(): - log.info(f'User {user.id} has an approved ManualVerification') - return True - - log.info(f'User {user.id} has no approved verifications') - return False - @classmethod def verifications_for_user(cls, user): """ diff --git a/lms/djangoapps/verify_student/tests/test_services.py b/lms/djangoapps/verify_student/tests/test_services.py index ab36d3b8bfd46a85c3695ba57f8f7e86afea9670..eeeca1f5e6d7348c50b97ba279732b4d8395d497 100644 --- a/lms/djangoapps/verify_student/tests/test_services.py +++ b/lms/djangoapps/verify_student/tests/test_services.py @@ -50,46 +50,6 @@ class TestIDVerificationService(ModuleStoreTestCase): attempt.save() assert IDVerificationService.user_is_verified(user), attempt.status - def test_user_has_ever_been_verified(self): - """ - Test to make sure we correctly answer whether a user has ever been verified. - """ - # Missing user - assert not IDVerificationService.user_has_ever_been_verified(None) - - # User without any attempts - photo_user = UserFactory.create() - assert not IDVerificationService.user_has_ever_been_verified(photo_user) - - # User without an approved attempt - attempt = SoftwareSecurePhotoVerification(user=photo_user, status='submitted') - attempt.save() - assert not IDVerificationService.user_has_ever_been_verified(photo_user) - - # User with a submitted, then an approved attempt - attempt = SoftwareSecurePhotoVerification(user=photo_user, status='approved') - attempt.save() - assert IDVerificationService.user_has_ever_been_verified(photo_user) - - # User with a manual approved attempt - manual_user = UserFactory.create() - attempt = ManualVerification(user=manual_user, status='approved') - attempt.save() - assert IDVerificationService.user_has_ever_been_verified(manual_user) - - # User with 2 manual approved attempts - attempt = ManualVerification(user=manual_user, status='approved') - attempt.save() - assert IDVerificationService.user_has_ever_been_verified(manual_user) - - # User with an SSO approved attempt, then a must_retry attempt - sso_user = UserFactory.create() - attempt = SSOVerification(user=sso_user, status='approved') - attempt.save() - attempt = SSOVerification(user=sso_user, status='must_retry') - attempt.save() - assert IDVerificationService.user_has_ever_been_verified(sso_user) - def test_user_has_valid_or_pending(self): """ Determine whether we have to prompt this user to verify, or if they've