From c15adf9cd93564f3e6f918810a806f5206bd5f45 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Wed, 31 Dec 2014 12:03:17 -0500 Subject: [PATCH] Set attempting_upgrade session flag in the new payment flow --- lms/djangoapps/verify_student/tests/test_views.py | 6 ++++++ lms/djangoapps/verify_student/views.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index 3fb52a2a6e..3561cf429b 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -993,6 +993,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase): PayAndVerifyView.PHOTO_ID_REQ, PayAndVerifyView.WEBCAM_REQ, ]) + self._assert_upgrade_session_flag(False) @ddt.data("expired", "denied") def test_start_flow_expired_or_denied_verification(self, verification_status): @@ -1331,6 +1332,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase): PayAndVerifyView.PHOTO_ID_REQ, PayAndVerifyView.WEBCAM_REQ, ]) + self._assert_upgrade_session_flag(True) def test_upgrade_already_verified(self): course = self._create_course("verified") @@ -1636,6 +1638,10 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase): 'verification_deadline': pay_and_verify_div['data-verification-deadline'] } + def _assert_upgrade_session_flag(self, is_upgrade): + """Check that the session flag for attempting an upgrade is set. """ + self.assertEqual(self.client.session.get('attempting_upgrade'), is_upgrade) + def _assert_redirects_to_dashboard(self, response): """Check that the page redirects to the student dashboard. """ self.assertRedirects(response, reverse('dashboard')) diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 5e1fec7ed7..eb2f406ef1 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -499,6 +499,10 @@ class PayAndVerifyView(View): 'donation_for_course', {} ).get(unicode(course_key), '') + # Remember whether the user is upgrading + # so we can fire an analytics event upon payment. + request.session['attempting_upgrade'] = (message == self.UPGRADE_MSG) + # Render the top-level page context = { 'user_full_name': full_name,