Commit 4eef6108 by Awais Qureshi

Merge pull request #8328 from edx/awais786/awais786/ECOM-1572-icrv-emails-format-new

ECOM-1572 implementing code to new branch.
parents 9bdf64d3 424e1f5b
......@@ -858,7 +858,7 @@ def submit_photos_for_verification(request):
def _compose_message_reverification_email(
course_key, user_id, related_assessment_location, status, is_secure
course_key, user_id, related_assessment_location, status, request
): # pylint: disable=invalid-name
"""
Compose subject and message for photo reverification email.
......@@ -885,14 +885,13 @@ def _compose_message_reverification_email(
context = {
"status": status,
"course_name": course.display_name_with_default,
"assessment": reverification_block.related_assessment,
"courseware_url": redirect_url
"assessment": reverification_block.related_assessment
}
# Allowed attempts is 1 if not set on verification block
allowed_attempts = 1 if reverification_block.attempts == 0 else reverification_block.attempts
user_attempts = VerificationStatus.get_user_attempts(user_id, course_key, related_assessment_location)
left_attempts = allowed_attempts - user_attempts
allowed_attempts = reverification_block.attempts + 1
used_attempts = VerificationStatus.get_user_attempts(user_id, course_key, related_assessment_location)
left_attempts = allowed_attempts - used_attempts
is_attempt_allowed = left_attempts > 0
verification_open = True
if reverification_block.due:
......@@ -902,9 +901,11 @@ def _compose_message_reverification_email(
context["is_attempt_allowed"] = is_attempt_allowed
context["verification_open"] = verification_open
context["due_date"] = get_default_time_display(reverification_block.due)
context["is_secure"] = is_secure
context["site"] = microsite.get_value('SITE_NAME', 'localhost')
context['platform_name'] = microsite.get_value('platform_name', settings.PLATFORM_NAME),
context['platform_name'] = settings.PLATFORM_NAME
context["used_attempts"] = used_attempts
context["allowed_attempts"] = allowed_attempts
context["support_link"] = microsite.get_value('email_from_address', settings.CONTACT_EMAIL)
re_verification_link = reverse(
'verify_student_incourse_reverify',
......@@ -913,7 +914,10 @@ def _compose_message_reverification_email(
related_assessment_location
)
)
context["reverify_link"] = re_verification_link
context["course_link"] = request.build_absolute_uri(redirect_url)
context["reverify_link"] = request.build_absolute_uri(re_verification_link)
message = render_to_string('emails/reverification_processed.txt', context)
log.info(
"Sending email to User_Id=%s. Attempts left for this user are %s. "
......@@ -1030,7 +1034,7 @@ def results_callback(request):
related_assessment_location = checkpoints[0].checkpoint_location
subject, message = _compose_message_reverification_email(
course_key, user_id, related_assessment_location, status, request.is_secure()
course_key, user_id, related_assessment_location, status, request
)
_send_email(user_id, subject, message)
......
<%namespace file="../main.html" import="stanford_theme_enabled" />
<%! from django.utils.translation import ugettext as _ %>
% if status == "approved":
${_("Your verification for course {course_name} and assessment {assessment} "
"has been passed."
).format(course_name=course_name, assessment=assessment)}
${_("We have successfully verified your identity for the {assessment} assessment in the {course_name} course."
).format(course_name=course_name, assessment=assessment)}
%else:
${_("Your verification for course {course_name} and assessment {assessment} "
"has failed."
).format(course_name=course_name, assessment=assessment)}
% elif is_attempt_allowed and verification_open: # if attempts are allowed and verification is still open.
${_("We could not verify your identity for the {assessment} assessment in the {course_name} course. You have used {used_attempts} out of {allowed_attempts} attempts to verify your identity."
).format(course_name=course_name, assessment=assessment, used_attempts=used_attempts, allowed_attempts=allowed_attempts)}
%if due_date:
${_("You must verify your identity before the assessment closes on {due_date}.").format(due_date=due_date)}
%endif
% if not is_attempt_allowed:
${_("You have reached your allowed attempts limit. No more retakes allowed.")}
% elif not verification_open:
${_("Assessment date has passed and retake not allowed.")}
% else:
% if due_date:
${_("Assessment closes on {due_date}.".format(due_date=due_date))}
% else:
${_("Assessment is open and you have {left_attempts} attempt(s) remaining.".format(left_attempts=left_attempts))}
% endif
${_("To try to verify your identity again, select the following link:")}
${reverify_link}
${_("Click on link below to re-verify:")}
% if is_secure:
https://${ site }${ reverify_link }
% else:
http://${ site }${ reverify_link }
% endif
% elif not is_attempt_allowed or not verification_open: # if attempts are not allowed or verification window is closed
${_("We could not verify your identity for the {assessment} assessment in the {course_name} course. You have used {used_attempts} out of {allowed_attempts} attempts to verify your identity, and verification is no longer possible."
).format(course_name=course_name, assessment=assessment, used_attempts=used_attempts, allowed_attempts=allowed_attempts)}
%endif
% endif
% endif
${_("To go to the courseware, select the following link:")}
${course_link}
${_("Click on link below to go to the courseware:")}
% if is_secure:
https://${ site }${ courseware_url }
% else:
http://${ site }${ courseware_url }
% endif
${_("If you have any questions, you can contact student support at {support_link}.").format(support_link=support_link)}
${_("The {platform_name} Team.").format(platform_name=platform_name)}
${_("Thanks,")}
${_("The {platform_name} team").format(platform_name=platform_name)}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment