Commit 80ae7176 by Will Daly

Merge pull request #7071 from edx/will/ecom-1108

Preserve enrollment_action and course_id querystring params in header 'Sign In' button
parents 169175b7 0f17d8c9
...@@ -408,6 +408,26 @@ class StudentAccountLoginAndRegistrationTest(UrlResetMixin, ModuleStoreTestCase) ...@@ -408,6 +408,26 @@ class StudentAccountLoginAndRegistrationTest(UrlResetMixin, ModuleStoreTestCase)
response = self.client.get(reverse(url_name)) response = self.client.get(reverse(url_name))
self.assertRedirects(response, reverse("dashboard")) self.assertRedirects(response, reverse("dashboard"))
@ddt.data(
(False, "account_login"),
(False, "account_login"),
(True, "account_login"),
(True, "account_register"),
)
@ddt.unpack
def test_login_and_registration_form_signin_preserves_params(self, is_edx_domain, url_name):
params = {
'enrollment_action': 'enroll',
'course_id': 'edX/DemoX/Demo_Course'
}
with mock.patch.dict(settings.FEATURES, {'IS_EDX_DOMAIN': is_edx_domain}):
response = self.client.get(reverse(url_name), params)
# The response should have a "Sign In" button with the URL
# that preserves the querystring params
self.assertContains(response, "login?course_id=edX%2FDemoX%2FDemo_Course&enrollment_action=enroll")
@mock.patch.dict(settings.FEATURES, {"ENABLE_THIRD_PARTY_AUTH": False}) @mock.patch.dict(settings.FEATURES, {"ENABLE_THIRD_PARTY_AUTH": False})
@ddt.data("account_login", "account_register") @ddt.data("account_login", "account_register")
def test_third_party_auth_disabled(self, url_name): def test_third_party_auth_disabled(self, url_name):
......
...@@ -114,6 +114,11 @@ def login_and_registration_form(request, initial_mode="login"): ...@@ -114,6 +114,11 @@ def login_and_registration_form(request, initial_mode="login"):
'login_form_desc': form_descriptions['login'], 'login_form_desc': form_descriptions['login'],
'registration_form_desc': form_descriptions['registration'], 'registration_form_desc': form_descriptions['registration'],
'password_reset_form_desc': form_descriptions['password_reset'], 'password_reset_form_desc': form_descriptions['password_reset'],
# We need to pass these parameters so that the header's
# "Sign In" button preserves the querystring params.
'enrollment_action': request.GET.get('enrollment_action'),
'course_id': request.GET.get('course_id')
} }
return render_to_response('student_account/login_and_register.html', context) return render_to_response('student_account/login_and_register.html', context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment