From 91622640d8701f5cb680080be6ae858f68e5121f Mon Sep 17 00:00:00 2001 From: Zacharis278 Date: Fri, 4 Oct 2024 10:23:32 -0400 Subject: [PATCH] feat: separate PhotoVerification events --- .../docs/diagrams/certificate_generation.dsl | 1 + lms/djangoapps/certificates/signals.py | 2 ++ lms/djangoapps/verify_student/models.py | 11 +++-------- openedx/core/djangoapps/signals/signals.py | 7 +++++++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lms/djangoapps/certificates/docs/diagrams/certificate_generation.dsl b/lms/djangoapps/certificates/docs/diagrams/certificate_generation.dsl index d6b31870f115..e5b66bf3b2ab 100644 --- a/lms/djangoapps/certificates/docs/diagrams/certificate_generation.dsl +++ b/lms/djangoapps/certificates/docs/diagrams/certificate_generation.dsl @@ -33,6 +33,7 @@ workspace { grades_app -> signal_handlers "Emits COURSE_GRADE_NOW_PASSED signal" verify_student_app -> signal_handlers "Emits IDV_ATTEMPT_APPROVED signal" verify_student_app -> signal_handlers "Emits LEARNER_SSO_VERIFIED signal" + verify_student_app -> signal_handlers "Emits PHOTO_VERIFICATION_APPROVED signal" student_app -> signal_handlers "Emits ENROLLMENT_TRACK_UPDATED signal" allowlist -> signal_handlers "Emits APPEND_CERTIFICATE_ALLOWLIST signal" signal_handlers -> generation_handler "Invokes generate_allowlist_certificate()" diff --git a/lms/djangoapps/certificates/signals.py b/lms/djangoapps/certificates/signals.py index 5f2f792b22fd..39042ff34164 100644 --- a/lms/djangoapps/certificates/signals.py +++ b/lms/djangoapps/certificates/signals.py @@ -33,6 +33,7 @@ COURSE_GRADE_NOW_FAILED, COURSE_GRADE_NOW_PASSED, LEARNER_SSO_VERIFIED, + PHOTO_VERIFICATION_APPROVED, ) from openedx_events.learning.signals import EXAM_ATTEMPT_REJECTED, IDV_ATTEMPT_APPROVED @@ -143,6 +144,7 @@ def _handle_id_verification_approved(user): @receiver(LEARNER_SSO_VERIFIED, dispatch_uid="sso_learner_verified") +@receiver(PHOTO_VERIFICATION_APPROVED, dispatch_uid="photo_verification_approved") def _listen_for_sso_verification_approved(sender, user, **kwargs): # pylint: disable=unused-argument """ Listen for a signal on SSOVerification indicating that the user has been verified. diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 7379050ab905..4bcfb248cb9c 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -42,7 +42,7 @@ rsa_decrypt, rsa_encrypt ) -from openedx.core.djangoapps.signals.signals import LEARNER_SSO_VERIFIED +from openedx.core.djangoapps.signals.signals import LEARNER_SSO_VERIFIED, PHOTO_VERIFICATION_APPROVED from openedx.core.storage import get_storage from .utils import auto_verify_for_testing_enabled, earliest_allowed_verification_date, submit_request_to_ss @@ -453,17 +453,12 @@ def approve(self, user_id=None, service=""): self.save() # Emit signal to find and generate eligible certificates - # This model uses the LEARNER_SSO_VERIFIED signal for backwards compatibility with changes - # to existing records. This model is being deprecated and all future IDV records - # will use the new VerificationAttempt model and corresponding openedx events signal. - # This is temporary until this model can be removed. - # DEPR details: https://github.com/openedx/edx-platform/issues/35128 - LEARNER_SSO_VERIFIED.send_robust( + PHOTO_VERIFICATION_APPROVED.send_robust( sender=PhotoVerification, user=self.user, ) - message = 'LEARNER_SSO_VERIFIED signal fired for {user} from PhotoVerification' + message = 'PHOTO_VERIFICATION_APPROVED signal fired for {user} from PhotoVerification' log.info(message.format(user=self.user.username)) @status_before_must_be("ready", "must_retry") diff --git a/openedx/core/djangoapps/signals/signals.py b/openedx/core/djangoapps/signals/signals.py index b9dcbfbadd8e..24624464ab91 100644 --- a/openedx/core/djangoapps/signals/signals.py +++ b/openedx/core/djangoapps/signals/signals.py @@ -40,5 +40,12 @@ # providing_args=['user'] LEARNER_SSO_VERIFIED = Signal() +# Signal that indicates a user has been verified via verify_studnet.PhotoVerification for certificate purposes +# Please note that this signal and the corresponding PhotoVerification model are planned for deprecation. +# Future implementations of IDV will use the verify_student.VerificationAttempt model and corresponding +# openedx events. +# DEPR: https://github.com/openedx/edx-platform/issues/35128 +PHOTO_VERIFICATION_APPROVED = Signal() + # providing_args=['user'] USER_ACCOUNT_ACTIVATED = Signal() # Signal indicating email verification