diff --git a/common/djangoapps/course_modes/tests/test_views.py b/common/djangoapps/course_modes/tests/test_views.py index 74e3b4b1b5..30b242671b 100644 --- a/common/djangoapps/course_modes/tests/test_views.py +++ b/common/djangoapps/course_modes/tests/test_views.py @@ -32,44 +32,22 @@ class CourseModeViewTest(ModuleStoreTestCase): self.client.login(username=self.user.username, password="edx") @ddt.data( - # is_active?, enrollment_mode, upgrade?, redirect?, auto_register? - (True, 'verified', True, True, False), # User is already verified - (True, 'verified', False, True, False), # User is already verified - (True, 'honor', True, False, False), # User isn't trying to upgrade - (True, 'honor', False, True, False), # User is trying to upgrade - (True, 'audit', True, False, False), # User isn't trying to upgrade - (True, 'audit', False, True, False), # User is trying to upgrade - (False, 'verified', True, False, False), # User isn't active - (False, 'verified', False, False, False), # User isn't active - (False, 'honor', True, False, False), # User isn't active - (False, 'honor', False, False, False), # User isn't active - (False, 'audit', True, False, False), # User isn't active - (False, 'audit', False, False, False), # User isn't active - - # When auto-registration is enabled, users may already be - # registered when they reach the "choose your track" - # page. In this case, we do NOT want to redirect them - # to the dashboard, because we want to give them the option - # to enter the verification/payment track. - # TODO (ECOM-16): based on the outcome of the auto-registration AB test, - # either keep these tests or remove them. In either case, - # remove the "auto_register" flag from this test case. - (True, 'verified', True, False, True), - (True, 'verified', False, True, True), - (True, 'honor', True, False, True), - (True, 'honor', False, False, True), - (True, 'audit', True, False, True), - (True, 'audit', False, False, True), + # is_active?, enrollment_mode, upgrade?, redirect? + (True, 'verified', True, False), # User has an active verified enrollment and is trying to upgrade + (True, 'verified', False, True), # User has an active verified enrollment and is not trying to upgrade + (True, 'honor', True, False), # User has an active honor enrollment and is trying to upgrade + (True, 'honor', False, False), # User has an active honor enrollment and is not trying to upgrade + (True, 'audit', True, False), # User has an active audit enrollment and is trying to upgrade + (True, 'audit', False, False), # User has an active audit enrollment and is not trying to upgrade + (False, 'verified', True, True), # User has an inactive verified enrollment and is trying to upgrade + (False, 'verified', False, True), # User has an inactive verified enrollment and is not trying to upgrade + (False, 'honor', True, True), # User has an inactive honor enrollment and is trying to upgrade + (False, 'honor', False, True), # User has an inactive honor enrollment and is not trying to upgrade + (False, 'audit', True, True), # User has an inactive audit enrollment and is trying to upgrade + (False, 'audit', False, True), # User has an inactive audit enrollment and is not trying to upgrade ) @ddt.unpack - def test_redirect_to_dashboard(self, is_active, enrollment_mode, upgrade, redirect, auto_register): - - # TODO (ECOM-16): Remove once we complete the auto-reg AB test. - if auto_register: - session = self.client.session - session['auto_register'] = True - session.save() - + def test_redirect_to_dashboard(self, is_active, enrollment_mode, upgrade, redirect): # Create the course modes for mode in ('audit', 'honor', 'verified'): CourseModeFactory(mode_slug=mode, course_id=self.course.id) @@ -96,6 +74,17 @@ class CourseModeViewTest(ModuleStoreTestCase): else: self.assertEquals(response.status_code, 200) + def test_redirect_to_dashboard_no_enrollment(self): + # Create the course modes + for mode in ('audit', 'honor', 'verified'): + CourseModeFactory(mode_slug=mode, course_id=self.course.id) + + # User visits the track selection page directly without ever enrolling + url = reverse('course_modes_choose', args=[unicode(self.course.id)]) + response = self.client.get(url) + + self.assertRedirects(response, reverse('dashboard')) + @ddt.data( '', '1,,2', @@ -114,6 +103,14 @@ class CourseModeViewTest(ModuleStoreTestCase): suggested_prices=price_list ) + # Enroll the user in the test course to emulate + # automatic enrollment + CourseEnrollmentFactory( + is_active=True, + course_id=self.course.id, + user=self.user + ) + # Verify that the prices render correctly response = self.client.get( reverse('course_modes_choose', args=[unicode(self.course.id)]), @@ -124,16 +121,7 @@ class CourseModeViewTest(ModuleStoreTestCase): # TODO: Fix it so that response.templates works w/ mako templates, and then assert # that the right template rendered - # TODO (ECOM-16): Remove the auto-registration flag once the AB test is complete - # and we choose the winner as the default - @ddt.data(True, False) - def test_professional_registration(self, auto_register): - - # TODO (ECOM-16): Remove once we complete the auto-reg AB test. - if auto_register: - self.client.session['auto_register'] = True - self.client.session.save() - + def test_professional_registration(self): # The only course mode is professional ed CourseModeFactory(mode_slug='professional', course_id=self.course.id) @@ -167,22 +155,12 @@ class CourseModeViewTest(ModuleStoreTestCase): 'unsupported': {'unsupported_mode': True}, } - # TODO (ECOM-16): Remove the auto-register flag once the AB-test completes - # and we default it to enabled or disabled. @ddt.data( - (False, 'honor', 'dashboard'), - (False, 'verified', 'show_requirements'), - (True, 'honor', 'dashboard'), - (True, 'verified', 'show_requirements'), + ('honor', 'dashboard'), + ('verified', 'show_requirements'), ) @ddt.unpack - def test_choose_mode_redirect(self, auto_register, course_mode, expected_redirect): - - # TODO (ECOM-16): Remove once we complete the auto-reg AB test. - if auto_register: - self.client.session['auto_register'] = True - self.client.session.save() - + def test_choose_mode_redirect(self, course_mode, expected_redirect): # Create the course modes for mode in ('audit', 'honor', 'verified'): CourseModeFactory(mode_slug=mode, course_id=self.course.id) @@ -221,23 +199,24 @@ class CourseModeViewTest(ModuleStoreTestCase): expected_amount = decimal.Decimal(self.POST_PARAMS_FOR_COURSE_MODE['verified']['contribution']) self.assertEqual(actual_amount, expected_amount) - # TODO (ECOM-16): Remove auto-register booleans once the AB-test completes - @ddt.data(False, True) - def test_successful_honor_enrollment(self, auto_register): - # TODO (ECOM-16): Remove once we complete the auto-reg AB test. - if auto_register: - self.client.session['auto_register'] = True - self.client.session.save() - + def test_successful_honor_enrollment(self): # Create the course modes for mode in ('honor', 'verified'): CourseModeFactory(mode_slug=mode, course_id=self.course.id) - # Choose the mode (POST request) + # Enroll the user in the default mode (honor) to emulate + # automatic enrollment + params = { + 'enrollment_action': 'enroll', + 'course_id': unicode(self.course.id) + } + self.client.post(reverse('change_enrollment'), params) + + # Explicitly select the honor mode (POST request) choose_track_url = reverse('course_modes_choose', args=[unicode(self.course.id)]) self.client.post(choose_track_url, self.POST_PARAMS_FOR_COURSE_MODE['honor']) - # Verify the enrollment + # Verify that the user's enrollment remains unchanged mode, is_active = CourseEnrollment.enrollment_mode_for_user(self.user, self.course.id) self.assertEqual(mode, 'honor') self.assertEqual(is_active, True) diff --git a/common/djangoapps/course_modes/views.py b/common/djangoapps/course_modes/views.py index 531069b2f6..b70e9e3028 100644 --- a/common/djangoapps/course_modes/views.py +++ b/common/djangoapps/course_modes/views.py @@ -49,32 +49,17 @@ class ChooseModeView(View): """ course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) - enrollment_mode, is_active = CourseEnrollment.enrollment_mode_for_user(request.user, course_key) + upgrade = request.GET.get('upgrade', False) request.session['attempting_upgrade'] = upgrade - # TODO (ECOM-16): Remove once the AB-test of auto-registration completes - auto_register = request.session.get('auto_register', False) - - # Inactive users always need to re-register - # Verified and professional users do not need to register or upgrade - # Registered users who are not trying to upgrade do not need to re-register - if not auto_register: - go_to_dashboard = ( - is_active and - (not upgrade or enrollment_mode in ['verified', 'professional']) - ) - - # If auto-registration is enabled, then students might already be registered, + # Students will already have an active course enrollment at this stage, # but we should still show them the "choose your track" page so they have # the option to enter the verification/payment flow. - # TODO (ECOM-16): Based on the results of the AB-test, set the default behavior to - # either enable or disable auto-registration. - else: - go_to_dashboard = ( - not upgrade and enrollment_mode in ['verified', 'professional'] - ) + go_to_dashboard = ( + not upgrade and enrollment_mode in ['verified', 'professional'] + ) if go_to_dashboard: return redirect(reverse('dashboard')) @@ -92,6 +77,16 @@ class ChooseModeView(View): ) ) + # If a user's course enrollment is inactive at this stage, the track + # selection page may have been visited directly, so we should redirect + # the user to their dashboard. By the time the user gets here during the + # normal registration process, they will already have an activated enrollment; + # the button appearing on the track selection page only redirects the user to + # the dashboard, and we don't want the user to be confused when they click the + # honor button and are taken to their dashboard without being enrolled. + if not is_active: + return redirect(reverse('dashboard')) + donation_for_course = request.session.get("donation_for_course", {}) chosen_price = donation_for_course.get(unicode(course_key), None) @@ -106,7 +101,6 @@ class ChooseModeView(View): "error": error, "upgrade": upgrade, "can_audit": "audit" in modes, - "autoreg": auto_register } if "verified" in modes: context["suggested_prices"] = [ @@ -155,10 +149,10 @@ class ChooseModeView(View): if requested_mode not in allowed_modes: return HttpResponseBadRequest(_("Enrollment mode not supported")) - # TODO (ECOM-16): Remove if the experimental variant wins. Functionally, - # it doesn't matter, but it will avoid hitting the database. if requested_mode == 'honor': - CourseEnrollment.enroll(user, course_key, requested_mode) + # The user will have already been enrolled in the honor mode at this + # point, so we just redirect them to the dashboard, thereby avoiding + # hitting the database a second time attempting to enroll them. return redirect(reverse('dashboard')) mode_info = allowed_modes[requested_mode] diff --git a/common/djangoapps/external_auth/tests/test_shib.py b/common/djangoapps/external_auth/tests/test_shib.py index 3b9668aedc..fa09501e41 100644 --- a/common/djangoapps/external_auth/tests/test_shib.py +++ b/common/djangoapps/external_auth/tests/test_shib.py @@ -14,7 +14,6 @@ from django.test.client import RequestFactory, Client as DjangoTestClient from django.test.utils import override_settings from django.core.urlresolvers import reverse from django.contrib.auth.models import AnonymousUser, User -from django.contrib.sessions.middleware import SessionMiddleware from django.utils.importlib import import_module from xmodule.modulestore.tests.factories import CourseFactory @@ -511,10 +510,6 @@ class ShibSPTest(ModuleStoreTestCase): for student in [shib_student, other_ext_student, int_student]: request = self.request_factory.post('/change_enrollment') - # Add a session to the request - SessionMiddleware().process_request(request) - request.session.save() - request.POST.update({'enrollment_action': 'enroll', 'course_id': course.id.to_deprecated_string()}) request.user = student diff --git a/common/djangoapps/student/tests/test_enrollment.py b/common/djangoapps/student/tests/test_enrollment.py index 58a32dd312..818c9bd9b6 100644 --- a/common/djangoapps/student/tests/test_enrollment.py +++ b/common/djangoapps/student/tests/test_enrollment.py @@ -45,34 +45,26 @@ class EnrollmentTest(ModuleStoreTestCase): reverse('course_modes_choose', kwargs={'course_id': unicode(self.course.id)}) ] - # TODO (ECOM-16): We need separate test cases for both conditions in the auto-registration - # AB-test. Once we get the results of that test, we should - # remove the losing condition from this test. @ddt.data( # Default (no course modes in the database) # Expect that we're redirected to the dashboard # and automatically enrolled as "honor" - ([], '', 'honor', False), - ([], '', 'honor', True), + ([], '', 'honor'), # Audit / Verified / Honor - # We should always go to the "choose your course" page, - # If auto-registration is enabled, we should also be registered - # as "honor" by default. - (['honor', 'verified', 'audit'], 'course_modes_choose', None, False), - (['honor', 'verified', 'audit'], 'course_modes_choose', 'honor', True), + # We should always go to the "choose your course" page. + # We should also be enrolled as "honor" by default. + (['honor', 'verified', 'audit'], 'course_modes_choose', 'honor'), # Professional ed # Expect that we're sent to the "choose your track" page # (which will, in turn, redirect us to a page where we can verify/pay) - # Even if auto registration is enabled, we should NOT be auto-registered, - # because that would be giving away an expensive course for free :) - (['professional'], 'course_modes_choose', None, False), - (['professional'], 'course_modes_choose', None, True), - + # We should NOT be auto-enrolled, because that would be giving + # away an expensive course for free :) + (['professional'], 'course_modes_choose', None), ) @ddt.unpack - def test_enroll(self, course_modes, next_url, enrollment_mode, auto_reg): + def test_enroll(self, course_modes, next_url, enrollment_mode): # Create the course modes (if any) required for this test case for mode_slug in course_modes: CourseModeFactory.create( @@ -90,16 +82,10 @@ class EnrollmentTest(ModuleStoreTestCase): ) # Enroll in the course and verify the URL we get sent to - resp = self._change_enrollment('enroll', auto_reg=auto_reg) + resp = self._change_enrollment('enroll') self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content, full_url) - # TODO (ECOM-16): If auto-registration is enabled, check that we're - # storing the auto-reg flag in the user's session - if auto_reg: - self.assertIn('auto_register', self.client.session) - self.assertTrue(self.client.session['auto_register']) - # If we're not expecting to be enrolled, verify that this is the case if enrollment_mode is None: self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course.id)) @@ -111,53 +97,10 @@ class EnrollmentTest(ModuleStoreTestCase): self.assertTrue(is_active) self.assertEqual(course_mode, enrollment_mode) - # TODO (ECOM-16): Remove once the auto-registration A/B test completes. - def test_enroll_from_redirect_autoreg(self): - # Bugfix (ECOM-199): Visitors removed from auto-enroll pool - # if they need to authenticate while attempting to enroll. - # If a user is (a) in the experimental condition of the A/B test (autoreg enabled) - # and (b) is not logged in when registering for a course, then - # the user will be redirected to the "control" URL (change_enrollment) - # instead of the experimental URL (change_enrollment_autoreg) - # We work around this by setting a flag in the session, such that - # if a user is *ever* in the experimental condition, they remain - # in the experimental condition. - for mode_slug in ['honor', 'audit', 'verified']: - CourseModeFactory.create( - course_id=self.course.id, - mode_slug=mode_slug, - mode_display_name=mode_slug - ) - - # Log out, so we're no longer authenticated - self.client.logout() - - # Visit the experimental condition URL - resp = self._change_enrollment('enroll', auto_reg=True) - - # Expect that we're denied (since we're not authenticated) - # and instead are redirected to the login page - self.assertEqual(resp.status_code, 403) - - # Log the user in - self.client.login(username=self.USERNAME, password=self.PASSWORD) - - # Go to the control URL - # This simulates what the JavaScript client does after getting a 403 response - # from the register button. - resp = self._change_enrollment('enroll') - - # Expect that we're auto-enrolled (even though we used the control URL the second time) - self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course.id)) - - # Expect that the auto register flag is still set in the user's session - self.assertIn('auto_register', self.client.session) - self.assertTrue(self.client.session['auto_register']) - - def test_enroll_from_redirect_autoreg_third_party(self): + def test_enroll_from_third_party_redirect(self): """ Test that, when a user visits the registration page *after* visiting a course, - if they go on to register and/or log in via third-party auth, they'll be registered + if they go on to register and/or log in via third-party auth, they'll be enrolled in that course. The testing here is a bit hackish, since we just ping the registration page, then @@ -173,31 +116,6 @@ class EnrollmentTest(ModuleStoreTestCase): change_enrollment_third_party(is_register=True, strategy=strategy, user=self.user) self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course.id)) - # TODO (ECOM-16): Remove once the auto-registration A/B test completes - def test_enroll_auto_registration_excluded_course(self): - # Create the course modes - for mode_slug in ['honor', 'audit', 'verified']: - CourseModeFactory.create( - course_id=self.course.id, - mode_slug=mode_slug, - mode_display_name=mode_slug, - ) - - # Visit the experimental condition URL (when the course is NOT excluded) - # This should place us into the experimental condition flow - self._change_enrollment('enroll', auto_reg=True) - - # Unenroll from the course (we were registered because auto enroll was enabled) - self._change_enrollment('unenroll') - - # Register for the course again, with the course excluded - # At this point, we should NOT be in the experimental condition flow - excluded_course_ids = [self.course.id.to_deprecated_string()] - with self.settings(AUTO_REGISTRATION_AB_TEST_EXCLUDE_COURSES=excluded_course_ids): - self._change_enrollment('enroll') - self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course.id)) - self.assertNotIn('auto_register', self.client.session) - def test_unenroll(self): # Enroll the student in the course CourseEnrollment.enroll(self.user, self.course.id, mode="honor") @@ -238,9 +156,8 @@ class EnrollmentTest(ModuleStoreTestCase): resp = self._change_enrollment('unenroll', course_id="edx/") self.assertEqual(resp.status_code, 400) - def _change_enrollment(self, action, course_id=None, auto_reg=False): - """ - Change the student's enrollment status in a course. + def _change_enrollment(self, action, course_id=None): + """Change the student's enrollment status in a course. Args: action (string): The action to perform (either "enroll" or "unenroll") @@ -249,9 +166,6 @@ class EnrollmentTest(ModuleStoreTestCase): course_id (unicode): If provided, use this course ID. Otherwise, use the course ID created in the setup for this test. - auto_reg (boolean): Whether to use the auto-registration hook. - TODO (ECOM-16): remove this once we complete the AB test for auto-registration. - Returns: Response @@ -259,13 +173,8 @@ class EnrollmentTest(ModuleStoreTestCase): if course_id is None: course_id = unicode(self.course.id) - url = ( - reverse('change_enrollment') - if not auto_reg - else reverse('change_enrollment_autoreg') - ) params = { 'enrollment_action': action, 'course_id': course_id } - return self.client.post(url, params) + return self.client.post(reverse('change_enrollment'), params) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index ba94f01d5f..14be87b300 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -726,7 +726,7 @@ def try_change_enrollment(request): @require_POST @commit_on_success_with_read_committed -def change_enrollment(request, auto_register=False, check_access=True): +def change_enrollment(request, check_access=True): """ Modify the enrollment status for the logged-in user. @@ -742,37 +742,21 @@ def change_enrollment(request, auto_register=False, check_access=True): happens. This function should only be called from an AJAX request or as a post-login/registration helper, so the error messages in the responses should never actually be user-visible. - The original version of the change enrollment handler, - which does NOT perform auto-registration. - - TODO (ECOM-16): We created a second variation of this handler that performs - auto-registration for an AB-test. Depending on the results of that test, - we should make the winning implementation the default. Args: request (`Request`): The Django request object Keyword Args: - auto_register (boolean): If True, auto-register the user - for a default course mode when they first enroll - before sending them to the "choose your track" page + check_access (boolean): If True, we check that an accessible course actually + exists for the given course_key before we enroll the student. + The default is set to False to avoid breaking legacy code or + code with non-standard flows (ex. beta tester invitations), but + for any standard enrollment flow you probably want this to be True. Returns: Response """ - # Sets the auto_register flag, if that's desired - # TODO (ECOM-16): Remove this once the auto-registration A/B test completes - # If a user is in the experimental condition (auto-registration enabled), - # immediately set a session flag so they stay in the experimental condition. - # We keep them in the experimental condition even if later on the user - # tries to register using the control URL (e.g. because of a redirect from the login page, - # which is hard-coded to use the control URL). - if auto_register: - request.session['auto_register'] = True - if request.session.get('auto_register') and not auto_register: - auto_register = True - # Get the user user = request.user @@ -797,15 +781,6 @@ def change_enrollment(request, auto_register=False, check_access=True): ) return HttpResponseBadRequest(_("Invalid course id")) - # Don't execute auto-register for the set of courses excluded from auto-registration - # TODO (ECOM-16): Remove this once the auto-registration A/B test completes - # We've agreed to exclude certain courses from the A/B test. If we find ourselves - # registering for one of these courses, immediately switch to the control. - if unicode(course_id) in getattr(settings, 'AUTO_REGISTRATION_AB_TEST_EXCLUDE_COURSES', []): - auto_register = False - if 'auto_register' in request.session: - del request.session['auto_register'] - if action == "enroll": # Make sure the course exists # We don't do this check on unenroll, or a bad course id can't be unenrolled from @@ -814,73 +789,38 @@ def change_enrollment(request, auto_register=False, check_access=True): .format(user.username, course_id)) return HttpResponseBadRequest(_("Course id is invalid")) - # We use this flag to determine which condition of an AB-test - # for auto-registration we're currently in. - # (We have two URLs that both point to this view, but vary the - # value of `auto_register`) - # In the auto-registration case, we automatically register the student - # as "honor" before allowing them to choose a track. - # TODO (ECOM-16): Once the auto-registration AB-test is complete, delete - # one of these two conditions and remove the `auto_register` flag. - if auto_register: - available_modes = CourseMode.modes_for_course_dict(course_id) - - # Handle professional ed as a special case. - # If professional ed is included in the list of available modes, - # then do NOT automatically enroll the student (we want them to pay first!) - # By convention, professional ed should be the *only* available course mode, - # if it's included at all -- anything else is a misconfiguration. But if someone - # messes up and adds an additional course mode, we err on the side of NOT - # accidentally giving away free courses. - if "professional" not in available_modes: - # Enroll the user using the default mode (honor) - # We're assuming that users of the course enrollment table - # will NOT try to look up the course enrollment model - # by its slug. If they do, it's possible (based on the state of the database) - # for no such model to exist, even though we've set the enrollment type - # to "honor". - try: - CourseEnrollment.enroll(user, course_id, check_access=check_access) - except Exception: - return HttpResponseBadRequest(_("Could not enroll")) - - # If we have more than one course mode or professional ed is enabled, - # then send the user to the choose your track page. - # (In the case of professional ed, this will redirect to a page that - # funnels users directly into the verification / payment flow) - if len(available_modes) > 1 or "professional" in available_modes: - return HttpResponse( - reverse("course_modes_choose", kwargs={'course_id': unicode(course_id)}) - ) - - # Otherwise, there is only one mode available (the default) - return HttpResponse() - - # If auto-registration is disabled, do NOT register the student - # before sending them to the "choose your track" page. - # This is the control for the auto-registration AB-test. - else: - # If this course is available in multiple modes, redirect them to a page - # where they can choose which mode they want. - available_modes = CourseMode.modes_for_course(course_id) - if len(available_modes) > 1: - return HttpResponse( - reverse("course_modes_choose", kwargs={'course_id': unicode(course_id)}) - ) - - current_mode = available_modes[0] - # only automatically enroll people if the only mode is 'honor' - if current_mode.slug != 'honor': - return HttpResponse( - reverse("course_modes_choose", kwargs={'course_id': unicode(course_id)}) - ) + available_modes = CourseMode.modes_for_course_dict(course_id) + # Handle professional ed as a special case. + # If professional ed is included in the list of available modes, + # then do NOT automatically enroll the student (we want them to pay first!) + # By convention, professional ed should be the *only* available course mode, + # if it's included at all -- anything else is a misconfiguration. But if someone + # messes up and adds an additional course mode, we err on the side of NOT + # accidentally giving away free courses. + if "professional" not in available_modes: + # Enroll the user using the default mode (honor) + # We're assuming that users of the course enrollment table + # will NOT try to look up the course enrollment model + # by its slug. If they do, it's possible (based on the state of the database) + # for no such model to exist, even though we've set the enrollment type + # to "honor". try: - CourseEnrollment.enroll(user, course_id, mode=current_mode.slug, check_access=check_access) + CourseEnrollment.enroll(user, course_id, check_access=check_access) except Exception: return HttpResponseBadRequest(_("Could not enroll")) - return HttpResponse() + # If we have more than one course mode or professional ed is enabled, + # then send the user to the choose your track page. + # (In the case of professional ed, this will redirect to a page that + # funnels users directly into the verification / payment flow) + if len(available_modes) > 1 or "professional" in available_modes: + return HttpResponse( + reverse("course_modes_choose", kwargs={'course_id': unicode(course_id)}) + ) + + # Otherwise, there is only one mode available (the default) + return HttpResponse() elif action == "add_to_cart": # Pass the request handling to shoppingcart.views diff --git a/common/templates/course_modes/choose.html b/common/templates/course_modes/choose.html index 1d28a4d972..49d4559d0f 100644 --- a/common/templates/course_modes/choose.html +++ b/common/templates/course_modes/choose.html @@ -5,272 +5,145 @@ <%block name="bodyclass">register verification-process step-select-track ${'is-upgrading' if upgrade else ''}%block> <%block name="pagetitle"> - %if upgrade: - ${_("Upgrade Your Registration for {} | Choose Your Track").format(course_name)} - %else: - ${_("Register for {} | Choose Your Track").format(course_name)} + % if upgrade: + ${_("Upgrade Your Registration for {} | Choose Your Track").format(course_name)} + % else: + ${_("Register for {} | Choose Your Track").format(course_name)} %endif %block> <%block name="js_extra"> - + }); + %block> <%block name="content"> - -%if error: -
${error}
-