Merge pull request #24398 from edx/aj/remove-deprecated-idv-emails
Deprecate old idv emails
This commit is contained in:
@@ -1487,11 +1487,8 @@ class TestSubmitPhotosForVerification(MockS3BotoMixin, TestVerificationBase):
|
||||
"""
|
||||
if expect_email:
|
||||
# Verify that photo submission confirmation email was sent
|
||||
subject = _(u"{platform_name} ID Verification Photos Received").format(
|
||||
platform_name=settings.PLATFORM_NAME
|
||||
)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual(subject, mail.outbox[0].subject)
|
||||
self.assertEqual('Thank you for submitting your photos!', mail.outbox[0].subject)
|
||||
else:
|
||||
# Verify that photo submission confirmation email was not sent
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
@@ -1542,6 +1539,20 @@ class TestPhotoVerificationResultsCallback(ModuleStoreTestCase, TestVerification
|
||||
"""
|
||||
return True
|
||||
|
||||
def _assert_verification_approved_email(self):
|
||||
"""Check that a verification approved email was sent."""
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
email = mail.outbox[0]
|
||||
self.assertEqual(email.subject, 'Your édX ID verification was approved!')
|
||||
self.assertIn('Your édX ID verification photos have been approved', email.body)
|
||||
|
||||
def _assert_verification_denied_email(self):
|
||||
"""Check that a verification approved email was sent."""
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
email = mail.outbox[0]
|
||||
self.assertEqual(email.subject, 'Your édX Verification Has Been Denied')
|
||||
self.assertIn('The photos you submitted for ID verification were not accepted', email.body)
|
||||
|
||||
def test_invalid_json(self):
|
||||
"""
|
||||
Test for invalid json being posted by software secure.
|
||||
@@ -1657,8 +1668,7 @@ class TestPhotoVerificationResultsCallback(ModuleStoreTestCase, TestVerification
|
||||
self.assertIsNone(old_verification.expiry_date)
|
||||
self.assertIsNone(old_verification.expiry_email_date)
|
||||
self.assertEqual(response.content.decode('utf-8'), 'OK!')
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual(mail.outbox[0].content_subtype, 'html')
|
||||
self._assert_verification_approved_email()
|
||||
|
||||
@patch(
|
||||
'lms.djangoapps.verify_student.ssencrypt.has_valid_signature',
|
||||
@@ -1692,8 +1702,7 @@ class TestPhotoVerificationResultsCallback(ModuleStoreTestCase, TestVerification
|
||||
self.assertEqual(attempt.status, u'approved')
|
||||
self.assertEqual(attempt.expiry_date.date(), expiry_date.date())
|
||||
self.assertEqual(response.content.decode('utf-8'), 'OK!')
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual(mail.outbox[0].content_subtype, 'html')
|
||||
self._assert_verification_approved_email()
|
||||
|
||||
@patch(
|
||||
'lms.djangoapps.verify_student.ssencrypt.has_valid_signature',
|
||||
@@ -1724,8 +1733,7 @@ class TestPhotoVerificationResultsCallback(ModuleStoreTestCase, TestVerification
|
||||
self.assertEqual(attempt.error_code, u'Your photo doesn\'t meet standards.')
|
||||
self.assertEqual(attempt.error_msg, u'[{"photoIdReasons": ["Not provided"]}]')
|
||||
self.assertEqual(response.content.decode('utf-8'), 'OK!')
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual(mail.outbox[0].content_subtype, 'html')
|
||||
self._assert_verification_denied_email()
|
||||
|
||||
@patch(
|
||||
'lms.djangoapps.verify_student.ssencrypt.has_valid_signature',
|
||||
|
||||
@@ -1032,31 +1032,12 @@ class SubmitPhotosView(View):
|
||||
Send an email confirming that the user submitted photos
|
||||
for initial verification.
|
||||
"""
|
||||
if use_new_templates_for_id_verification_emails():
|
||||
lms_root_url = configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL)
|
||||
new_template_context = {
|
||||
'user': user,
|
||||
'dashboard_link': '{}{}'.format(lms_root_url, reverse('dashboard'))
|
||||
}
|
||||
return send_verification_confirmation_email(new_template_context)
|
||||
|
||||
lms_root_url = configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL)
|
||||
context = {
|
||||
'full_name': user.profile.name,
|
||||
'platform_name': configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME)
|
||||
'user': user,
|
||||
'dashboard_link': '{}{}'.format(lms_root_url, reverse('dashboard'))
|
||||
}
|
||||
|
||||
subject = _("{platform_name} ID Verification Photos Received").format(platform_name=context['platform_name'])
|
||||
message = render_to_string('emails/photo_submission_confirmation.txt', context)
|
||||
from_address = configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
|
||||
to_address = user.email
|
||||
|
||||
try:
|
||||
send_mail(subject, message, from_address, [to_address], fail_silently=False)
|
||||
except: # pylint: disable=bare-except
|
||||
# We catch all exceptions and log them.
|
||||
# It would be much, much worse to roll back the transaction due to an uncaught
|
||||
# exception than to skip sending the notification email.
|
||||
log.exception(u"Could not send notification email for initial verification for user %s", user.id)
|
||||
return send_verification_confirmation_email(context)
|
||||
|
||||
def _fire_event(self, user, event_name, parameters):
|
||||
"""
|
||||
@@ -1150,26 +1131,9 @@ def results_callback(request):
|
||||
log.debug(u'Approving verification for {}'.format(receipt_id))
|
||||
attempt.approve()
|
||||
|
||||
expiry_date = datetime.date.today() + datetime.timedelta(
|
||||
days=settings.VERIFY_STUDENT["DAYS_GOOD_FOR"]
|
||||
)
|
||||
|
||||
if use_new_templates_for_id_verification_emails():
|
||||
context = {'user': user, 'expiry_date': expiry_date.strftime("%m/%d/%Y")}
|
||||
send_verification_approved_email(context=context)
|
||||
else:
|
||||
verification_status_email_vars['expiry_date'] = expiry_date.strftime("%m/%d/%Y")
|
||||
verification_status_email_vars['full_name'] = user.profile.name
|
||||
subject = _(u"Your {platform_name} ID Verification Approved").format(
|
||||
platform_name=settings.PLATFORM_NAME
|
||||
)
|
||||
context = {
|
||||
'subject': subject,
|
||||
'template': 'emails/passed_verification_email.txt',
|
||||
'email': user.email,
|
||||
'email_vars': verification_status_email_vars
|
||||
}
|
||||
send_verification_status_email.delay(context)
|
||||
expiry_date = datetime.date.today() + datetime.timedelta(days=settings.VERIFY_STUDENT["DAYS_GOOD_FOR"])
|
||||
email_context = {'user': user, 'expiry_date': expiry_date.strftime("%m/%d/%Y")}
|
||||
send_verification_approved_email(context=email_context)
|
||||
|
||||
elif result == "FAIL":
|
||||
log.debug(u"Denying verification for %s", receipt_id)
|
||||
|
||||
Reference in New Issue
Block a user