Skip to content
Snippets Groups Projects
Commit 041becc8 authored by Bianca Severino's avatar Bianca Severino
Browse files

Implement waffle flag for IDV redirect

Created helper function to render url dynamically

Modify helper function to include reverify links

Fix code based on failing tests

Fixed query string in redirect URL
parent b479d511
No related branches found
Tags release-2020-12-18-19.16
No related merge requests found
......@@ -655,10 +655,13 @@ class VerificationDeadlineDate(DateSummary):
"""Maps verification state to a tuple of link text and location."""
return {
'verification-deadline-passed': (_('Learn More'), ''),
'verification-deadline-retry': (_('Retry Verification'), reverse('verify_student_reverify')),
'verification-deadline-retry': (
_('Retry Verification'),
IDVerificationService.get_verify_location('verify_student_reverify'),
),
'verification-deadline-upcoming': (
_('Verify My Identity'),
reverse('verify_student_verify_now', args=(self.course_id,))
IDVerificationService.get_verify_location('verify_student_verify_now', self.course_id),
)
}
......
......@@ -22,6 +22,7 @@ from util.query import use_read_replica_if_available
from lms.djangoapps.verify_student.message_types import VerificationExpiry
from lms.djangoapps.verify_student.models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification
from lms.djangoapps.verify_student.services import IDVerificationService
from openedx.core.djangoapps.ace_common.template_context import get_base_template_context
from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference
......@@ -190,7 +191,7 @@ class Command(BaseCommand):
message_context = get_base_template_context(site)
message_context.update({
'platform_name': settings.PLATFORM_NAME,
'lms_verification_link': '{}{}'.format(settings.LMS_ROOT_URL, reverse("verify_student_reverify")),
'lms_verification_link': IDVerificationService.email_reverify_url(),
'help_center_link': settings.ID_VERIFICATION_SUPPORT_LINK
})
......
......@@ -15,6 +15,7 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
from student.models import User
from .models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification
from .toggles import redirect_to_idv_microfrontend
from .utils import earliest_allowed_verification_date, most_recent_verification
log = logging.getLogger(__name__)
......@@ -46,7 +47,7 @@ class XBlockVerificationService(object):
"""
Returns the URL for a user to verify themselves.
"""
return reverse('verify_student_reverify')
return IDVerificationService.get_verify_location('verify_student_reverify')
class IDVerificationService(object):
......@@ -240,3 +241,38 @@ class IDVerificationService(object):
return 'Not ID Verified'
else:
return 'ID Verified'
@classmethod
def get_verify_location(cls, url_name, course_id=None):
"""
url_name is one of:
'verify_student_verify_now'
'verify_student_reverify'
Returns a string:
If waffle flag is active, returns URL for IDV microfrontend.
Else, returns URL for corresponding view.
"""
location = ''
if redirect_to_idv_microfrontend():
location = '{}/id-verification'.format(settings.ACCOUNT_MICROFRONTEND_URL)
if course_id:
location = location + '?{}'.format(str(course_id))
else:
if course_id:
location = reverse(url_name, args=[str(course_id)])
else:
location = reverse(url_name)
return location
@classmethod
def email_reverify_url(cls):
"""
Return a URL string for reverification emails:
If waffle flag is active, returns URL for IDV microfrontend.
Else, returns URL for reverify view.
"""
if redirect_to_idv_microfrontend():
return '{}/id-verification'.format(settings.ACCOUNT_MICROFRONTEND_URL)
else:
return '{}{}'.format(settings.LMS_ROOT_URL, reverse('verify_student_reverify'))
......@@ -27,3 +27,25 @@ USE_NEW_EMAIL_TEMPLATES = WaffleFlag(
def use_new_templates_for_id_verification_emails():
return USE_NEW_EMAIL_TEMPLATES.is_enabled()
# Waffle flag to redirect to the new IDV flow on the account microfrontend
# .. toggle_name: verify_student.redirect_to_idv_microfrontend
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Supports staged rollout to students for the new IDV flow.
# .. toggle_category: verify student
# .. toggle_use_cases: incremental_release, open_edx
# .. toggle_creation_date: 2020-07-09
# .. toggle_expiration_date: n/a
# .. toggle_warnings: n/a
# .. toggle_tickets: MST-318
# .. toggle_status: supported
REDIRECT_TO_IDV_MICROFRONTEND = WaffleFlag(
waffle_namespace=WAFFLE_FLAG_NAMESPACE,
flag_name='redirect_to_idv_microfrontend',
)
def redirect_to_idv_microfrontend():
return REDIRECT_TO_IDV_MICROFRONTEND.is_enabled()
......@@ -36,7 +36,6 @@ from lms.djangoapps.commerce.utils import EcommerceService, is_account_activatio
from lms.djangoapps.verify_student.emails import send_verification_approved_email, send_verification_confirmation_email
from lms.djangoapps.verify_student.image import InvalidImageData, decode_image_data
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification, VerificationDeadline
from lms.djangoapps.verify_student.services import IDVerificationService
from lms.djangoapps.verify_student.ssencrypt import has_valid_signature
from lms.djangoapps.verify_student.tasks import send_verification_status_email
from lms.djangoapps.verify_student.utils import can_verify_now
......@@ -54,6 +53,9 @@ from util.json_request import JsonResponse
from verify_student.toggles import use_new_templates_for_id_verification_emails
from xmodule.modulestore.django import modulestore
from .services import IDVerificationService
from .toggles import redirect_to_idv_microfrontend
log = logging.getLogger(__name__)
......@@ -510,7 +512,10 @@ class PayAndVerifyView(View):
if is_enrolled:
if already_paid:
# If the student has paid, but not verified, redirect to the verification flow.
url = reverse('verify_student_verify_now', kwargs=course_kwargs)
url = IDVerificationService.get_verify_location(
'verify_student_verify_now',
six.text_type(course_key)
)
else:
url = reverse('verify_student_start_flow', kwargs=course_kwargs)
......@@ -1139,7 +1144,7 @@ def results_callback(request):
log.debug(u"Denying verification for %s", receipt_id)
attempt.deny(json.dumps(reason), error_code=error_code)
status = "denied"
reverify_url = '{}{}'.format(settings.LMS_ROOT_URL, reverse("verify_student_reverify"))
reverify_url = IDVerificationService.email_reverify_url()
verification_status_email_vars['reasons'] = reason
verification_status_email_vars['reverify_url'] = reverify_url
verification_status_email_vars['faq_url'] = settings.ID_VERIFICATION_SUPPORT_LINK
......@@ -1229,6 +1234,8 @@ class ReverifyView(View):
verification_status = IDVerificationService.user_status(request.user)
expiration_datetime = IDVerificationService.get_expiration_datetime(request.user, ['approved'])
if can_verify_now(verification_status, expiration_datetime):
if redirect_to_idv_microfrontend():
return redirect('{}/id-verification'.format(settings.ACCOUNT_MICROFRONTEND_URL))
context = {
"user_full_name": request.user.profile.name,
"platform_name": configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
......
......@@ -3,12 +3,14 @@
<%!
import six
from django.conf import settings
from django.utils.http import urlencode, urlquote_plus
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.urls import reverse
from course_modes.models import CourseMode
from course_modes.helpers import enrollment_mode_display
from lms.djangoapps.verify_student.services import IDVerificationService
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
from openedx.core.djangolib.markup import HTML, Text
from openedx.features.course_experience import course_home_url_name
......@@ -26,7 +28,7 @@ from lms.djangoapps.experiments.utils import UPSELL_TRACKING_FLAG
%>
<%
reverify_link = reverse('verify_student_reverify')
reverify_link = IDVerificationService.get_verify_location('verify_student_reverify')
cert_name_short = course_overview.cert_name_short
if cert_name_short == "":
cert_name_short = settings.CERT_NAME_SHORT
......@@ -364,7 +366,7 @@ from lms.djangoapps.experiments.utils import UPSELL_TRACKING_FLAG
% endif
</div>
<div class="verification-cta">
<a href="${reverse('verify_student_verify_now', kwargs={'course_id': six.text_type(course_overview.id)})}" class="btn" data-course-id="${course_overview.id}">${_('Verify Now')}</a>
<a href="${IDVerificationService.get_verify_location('verify_student_verify_now', course_overview.id)}" class="btn" data-course-id="${course_overview.id}">${_('Verify Now')}</a>
</div>
% elif verification_status['status'] == VERIFY_STATUS_SUBMITTED:
<h4 class="message-title">${_('You have submitted your verification information.')}</h4>
......@@ -382,7 +384,7 @@ from lms.djangoapps.experiments.utils import UPSELL_TRACKING_FLAG
## Translators: start_link and end_link will be replaced with HTML tags;
## please do not translate these.
<p class="message-copy">${Text(_('Your current verification will expire in {days} days. {start_link}Re-verify your identity now{end_link} using a webcam and a government-issued photo ID.')).format(
start_link=HTML('<a href="{href}">').format(href=reverse('verify_student_reverify')),
start_link=HTML('<a href="{href}">').format(href=IDVerificationService.get_verify_location('verify_student_reverify')),
end_link=HTML('</a>'),
days=settings.VERIFY_STUDENT.get("EXPIRING_SOON_WINDOW")
)}
......
......@@ -3,6 +3,7 @@
<%!
from django.urls import reverse
from django.utils.translation import ugettext as _
from lms.djangoapps.verify_student.services import IDVerificationService
%>
%if verification_display:
......@@ -13,7 +14,7 @@ from django.utils.translation import ugettext as _
%if verification_expiry:
<p class="status-note"><span><b>${_("Warning")}: </b></span><i>${_("Your photo verification expires on {verification_expiry}. Please be aware photo verification can take up to three days once initiated and you will not be able to earn a certificate or take a proctored exam until approved.").format(verification_expiry=verification_expiry)}</i></p>
<div class="btn-reverify">
<a href="${reverse('verify_student_reverify')}" class="action action-reverify">${_("Resubmit Verification")}</a>
<a href="${IDVerificationService.get_verify_location('verify_student_reverify')}" class="action action-reverify">${_("Resubmit Verification")}</a>
</div>
%endif
</li>
......@@ -39,7 +40,7 @@ from django.utils.translation import ugettext as _
%endif
</p>
<div class="btn-reverify">
<a href="${reverse('verify_student_reverify')}" class="action action-reverify">${_("Resubmit Verification")}</a>
<a href="${IDVerificationService.get_verify_location('verify_student_reverify')}" class="action action-reverify">${_("Resubmit Verification")}</a>
</div>
</li>
%elif verification_status == 'expired':
......@@ -48,7 +49,7 @@ from django.utils.translation import ugettext as _
<p class="status-note">${_("Your verification has expired. To receive a verified certificate, you must submit a new photo of yourself and your government-issued photo ID before the verification deadline for your course.")}</p>
<p class="status-note"><span><b>${_("Warning")}: </b></span><i>${_(" Please be aware photo verification can take up to three days once initiated and you will not be able to earn a certificate or take a proctored exam until approved.")}</i></p>
<div class="btn-reverify">
<a href="${reverse('verify_student_reverify')}" class="action action-reverify">${_("Resubmit Verification")}</a>
<a href="${IDVerificationService.get_verify_location('verify_student_reverify')}" class="action action-reverify">${_("Resubmit Verification")}</a>
</div>
</li>
%endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment