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 eec973b598..655128d0c3 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,