Enter the new verification / payment flow using a GET param

Allow disabling of experiment
This commit is contained in:
Will Daly
2014-12-29 16:33:42 -08:00
parent 234691e446
commit a90f7ab1bf
10 changed files with 92 additions and 29 deletions

View File

@@ -655,8 +655,7 @@ class OrderItem(TimeStampedModel):
"""
return {}
@property
def additional_instruction_text(self):
def additional_instruction_text(self, **kwargs): # pylint: disable=unused-argument
"""
Individual instructions for this order item.
@@ -1378,8 +1377,7 @@ class CertificateItem(OrderItem):
"dashboard_url": reverse('dashboard'),
}
@property
def additional_instruction_text(self):
def additional_instruction_text(self, **kwargs):
refund_reminder = _(
"You have up to two weeks into the course to unenroll from the Verified Certificate option "
"and receive a full refund. To receive your refund, contact {billing_email}. "
@@ -1387,7 +1385,18 @@ class CertificateItem(OrderItem):
"Please do NOT include your credit card information."
).format(billing_email=settings.PAYMENT_SUPPORT_EMAIL)
if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT'):
# TODO (ECOM-188): When running the A/B test for
# separating the verified / payment flow, we want to add some extra instructions
# for users in the experimental group. In order to know the user is in the experimental
# group, we need to check a session variable. But at this point in the code,
# we're so deep into the request handling stack that we don't have access to the request.
# The approach taken here is to have the email template check the request session
# and pass in a kwarg to this function if it's set. The template already has
# access to the request (via edxmako middleware), so we don't need to change
# too much to make this work. Once the A/B test completes, though, we should
# clean this up by removing the `**kwargs` param and skipping the check
# for the session variable.
if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT') and kwargs.get('separate_verification'):
domain = microsite.get_value('SITE_NAME', settings.SITE_NAME)
path = reverse('verify_student_verify_later', kwargs={'course_id': unicode(self.course_id)})
verification_url = "http://{domain}{path}".format(domain=domain, path=path)
@@ -1542,8 +1551,7 @@ class Donation(OrderItem):
"""
return self.pk_with_subclass, set([self._tax_deduction_msg()])
@property
def additional_instruction_text(self):
def additional_instruction_text(self, **kwargs): # pylint: disable=unused-argument
"""Provide information about tax-deductible donations in the confirmation email.
Returns:

View File

@@ -249,7 +249,7 @@ class OrderTest(UrlResetMixin, ModuleStoreTestCase):
self.assertEquals('Order Payment Confirmation', mail.outbox[0].subject)
self.assertIn(settings.PAYMENT_SUPPORT_EMAIL, mail.outbox[0].body)
self.assertIn(unicode(cart.total_cost), mail.outbox[0].body)
self.assertIn(item.additional_instruction_text, mail.outbox[0].body)
self.assertIn(item.additional_instruction_text(), mail.outbox[0].body)
# Assert Google Analytics event fired for purchase.
self.mock_tracker.track.assert_called_once_with( # pylint: disable=maybe-no-member
@@ -280,7 +280,7 @@ class OrderTest(UrlResetMixin, ModuleStoreTestCase):
self.assertEquals(len(mail.outbox), 1)
# Verify that the verification reminder appears in the sent email.
self.assertIn(item.additional_instruction_text, mail.outbox[0].body)
self.assertIn(item.additional_instruction_text(), mail.outbox[0].body)
def test_purchase_item_failure(self):
# once again, we're testing against the specific implementation of

View File

@@ -1286,6 +1286,12 @@ class ReceiptRedirectTest(UrlResetMixin, ModuleStoreTestCase):
)
self.cart.purchase()
# Set the session flag indicating that the user is in the
# experimental group
session = self.client.session
session['separate-verified'] = True
session.save()
# Visit the receipt page
url = reverse('shoppingcart.views.show_receipt', args=[self.cart.id])
resp = self.client.get(url)
@@ -1302,6 +1308,28 @@ class ReceiptRedirectTest(UrlResetMixin, ModuleStoreTestCase):
self.assertRedirects(resp, redirect_url)
@patch.dict(settings.FEATURES, {'SEPARATE_VERIFICATION_FROM_PAYMENT': True})
def test_no_redirect_if_not_in_experimental_group(self):
# Purchase a verified certificate
CertificateItem.add_to_order(
self.cart,
self.course_key,
self.COST,
'verified'
)
self.cart.purchase()
# We do NOT set the session flag indicating that the user is in
# the experimental group.
# Visit the receipt page
url = reverse('shoppingcart.views.show_receipt', args=[self.cart.id])
resp = self.client.get(url)
# Since the user is not in the experimental group, expect
# that we see the usual receipt page (no redirect)
self.assertEqual(resp.status_code, 200)
@override_settings(MODULESTORE=MODULESTORE_CONFIG)
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_PAID_COURSE_REGISTRATION': True})

View File

@@ -798,7 +798,7 @@ def _show_receipt_html(request, order):
# TODO (ECOM-188): Once the A/B test of separate verified / payment flow
# completes, implement this in a more general way. For now,
# we simply redirect to the new receipt page (in verify_student).
if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT'):
if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT') and request.session.get('separate-verified', False):
if receipt_template == 'shoppingcart/verified_cert_receipt.html':
url = reverse(
'verify_student_payment_confirmation',

View File

@@ -754,15 +754,14 @@ def create_order(request):
"""
Submit PhotoVerification and create a new Order for this verified cert
"""
# TODO (ECOM-188): Once the A/B test of separating the payment/verified flow
# has completed, we can remove this flag and delete the photo verification
# step entirely (since it will be handled in a separate view).
submit_photo = True
if settings.FEATURES.get("SEPARATE_VERIFICATION_FROM_PAYMENT"):
submit_photo = (
'face_image' in request.POST and
'photo_id_image' in request.POST
)
# Only submit photos if photo data is provided by the client.
# TODO (ECOM-188): Once the A/B test of decoupling verified / payment
# completes, we may be able to remove photo submission from this step
# entirely.
submit_photo = (
'face_image' in request.POST and
'photo_id_image' in request.POST
)
if (
submit_photo and not

View File

@@ -54,7 +54,7 @@ from student.helpers import (
% endif
% if settings.FEATURES.get('ENABLE_VERIFIED_CERTIFICATES'):
% if enrollment.mode == "verified":
% if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT'):
% if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT') and request.session.get('separate-verified', False):
% if verification_status.get('status') in [VERIFY_STATUS_NEED_TO_VERIFY, VERIFY_STATUS_SUBMITTED]:
<span class="sts-enrollment" title="${_("Your verification is pending")}">
<span class="label">${_("Enrolled as: ")}</span>
@@ -131,7 +131,7 @@ from student.helpers import (
<%include file='_dashboard_certificate_information.html' args='cert_status=cert_status,course=course, enrollment=enrollment'/>
% endif
% if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT'):
% if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT') and request.session.get('separate-verified', True):
% if verification_status.get('status') in [VERIFY_STATUS_NEED_TO_VERIFY, VERIFY_STATUS_SUBMITTED, VERIFY_STATUS_APPROVED] and not is_course_blocked:
<div class="message message-status is-shown">
% if verification_status['status'] == VERIFY_STATUS_NEED_TO_VERIFY:
@@ -180,7 +180,7 @@ from student.helpers import (
<ul class="actions message-actions">
<li class="action-item">
% if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT'):
% if settings.FEATURES.get('SEPARATE_VERIFICATION_FROM_PAYMENT') and request.session.get('separate-verified', False):
<a class="action action-upgrade" href="${reverse('verify_student_upgrade_and_verify', kwargs={'course_id': unicode(course.id)})}" data-course-id="${course.id | h}" data-user="${user.username | h}">
% else:
<a class="action action-upgrade" href="${reverse('course_modes_choose', kwargs={'course_id': unicode(course.id)})}?upgrade=True" data-course-id="${course.id | h}" data-user="${user.username | h}">

View File

@@ -39,5 +39,5 @@ ${order.bill_to_country.upper()}
% endif
% for order_item in order_items:
${order_item.additional_instruction_text}
${order_item.additional_instruction_text(separate_verification=getattr(request, 'session', {}).get('separate-verified', False))}
% endfor