From c6a951796af52ee456d53d0e2ee242ed2d5998ab Mon Sep 17 00:00:00 2001 From: uzairr Date: Fri, 20 Apr 2018 13:08:15 +0500 Subject: [PATCH] Send email for the failed verification status Support Team need to handle bulk of tickets every month about the verification status of learners.To avoid it, suitable changes have done to send verification email to the learner. LEARNER-1488 --- lms/djangoapps/verify_student/tests/test_views.py | 1 + lms/djangoapps/verify_student/views.py | 13 +++++++++++++ lms/envs/aws.py | 1 + lms/envs/common.py | 1 + lms/templates/emails/failed_verification_email.txt | 11 +++++++++++ .../emails/successfull_verification_email.txt | 1 - 6 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 lms/templates/emails/failed_verification_email.txt diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index e8b6816e71..a8e0be66b2 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -1812,6 +1812,7 @@ class TestPhotoVerificationResultsCallback(ModuleStoreTestCase): self.assertEqual(attempt.error_code, u'Your photo doesn\'t meet standards.') self.assertEqual(attempt.error_msg, u'"Invalid photo"') self.assertEquals(response.content, 'OK!') + self.assertEqual(len(mail.outbox), 1) @mock.patch( 'lms.djangoapps.verify_student.ssencrypt.has_valid_signature', diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index d855eab69a..fb7886fa12 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -1179,6 +1179,19 @@ def results_callback(request): log.debug("Denying verification for %s", receipt_id) attempt.deny(json.dumps(reason), error_code=error_code) status = "denied" + email_template_context['reason'] = reason + email_template_context['reverify_url'] = reverse("verify_student_reverify") + email_template_context['faq_url'] = configuration_helpers.get_value( + 'ID_VERIFICATION_SUPPORT_LINK', + settings.SUPPORT_SITE_LINK + ) + context['email_template_context'] = email_template_context + context['subject'] = _("Your {platform_name} Verification Has Been Denied").format( + platform_name=settings.PLATFORM_NAME + ) + context['message'] = 'emails/failed_verification_email.txt' + send_verification_status_email(context) + elif result == "SYSTEM FAIL": log.debug("System failure for %s -- resetting to must_retry", receipt_id) attempt.system_error(json.dumps(reason), error_code=error_code) diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 8f904bfb29..c720c79355 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -294,6 +294,7 @@ MKTG_URL_LINK_MAP.update(ENV_TOKENS.get('MKTG_URL_LINK_MAP', {})) # Intentional defaults. SUPPORT_SITE_LINK = ENV_TOKENS.get('SUPPORT_SITE_LINK', SUPPORT_SITE_LINK) +ID_VERIFICATION_SUPPORT_LINK = ENV_TOKENS.get('ID_VERIFICATION_SUPPORT_LINK', SUPPORT_SITE_LINK) PASSWORD_RESET_SUPPORT_LINK = ENV_TOKENS.get('PASSWORD_RESET_SUPPORT_LINK', SUPPORT_SITE_LINK) ACTIVATION_EMAIL_SUPPORT_LINK = ENV_TOKENS.get( 'ACTIVATION_EMAIL_SUPPORT_LINK', SUPPORT_SITE_LINK diff --git a/lms/envs/common.py b/lms/envs/common.py index 8a1b384f85..c3b6294be0 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2368,6 +2368,7 @@ MKTG_URL_LINK_MAP = { STATIC_TEMPLATE_VIEW_DEFAULT_FILE_EXTENSION = 'html' SUPPORT_SITE_LINK = '' +ID_VERIFICATION_SUPPORT_LINK = '' PASSWORD_RESET_SUPPORT_LINK = '' ACTIVATION_EMAIL_SUPPORT_LINK = '' diff --git a/lms/templates/emails/failed_verification_email.txt b/lms/templates/emails/failed_verification_email.txt new file mode 100644 index 0000000000..365bce3a33 --- /dev/null +++ b/lms/templates/emails/failed_verification_email.txt @@ -0,0 +1,11 @@ +<%! from django.utils.translation import ugettext as _ %> + +${_("Sorry! The photos you submitted for ID verification were not accepted, for the following reason(s):")} + +${_("The photo(s) of you: {reason}").format(reason=reason)} + +${_("Resubmit Verification: {reverify_url}").format(reverify_url=reverify_url)} +$(_("ID Verification FAQ: {faq_url}").format(faq_url=faq_url) + +${_("Thank you,")} +${_("The {platform_name} team").format(platform_name=platform_name)} diff --git a/lms/templates/emails/successfull_verification_email.txt b/lms/templates/emails/successfull_verification_email.txt index 154cde7074..ad6e5e0969 100644 --- a/lms/templates/emails/successfull_verification_email.txt +++ b/lms/templates/emails/successfull_verification_email.txt @@ -7,5 +7,4 @@ ${_("Congratulations! Your ID verification process was successful.")} ${_("Your verification is effective for one year. It will expire on {expiry_date}").format(expiry_date=expiry_date)} ${_("Thank you,")} - ${_("The {platform_name} team").format(platform_name=platform_name)}