From 23a51a6515be07f089bc208088bfc5d3524f52f4 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 8 Dec 2014 08:34:51 -0500 Subject: [PATCH] Add email opt in to old login and register pages --- .../tests/test_login_registration_forms.py | 53 +++++++++++++++++++ common/djangoapps/student/views.py | 4 ++ lms/templates/login.html | 4 ++ lms/templates/main.html | 8 ++- lms/templates/register.html | 4 ++ 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/student/tests/test_login_registration_forms.py b/common/djangoapps/student/tests/test_login_registration_forms.py index 346ed4cdd9..a1feff45d9 100644 --- a/common/djangoapps/student/tests/test_login_registration_forms.py +++ b/common/djangoapps/student/tests/test_login_registration_forms.py @@ -1,6 +1,7 @@ """Tests for the login and registration form rendering. """ import urllib import unittest +from collections import OrderedDict from mock import patch from django.conf import settings from django.core.urlresolvers import reverse @@ -125,6 +126,29 @@ class LoginFormTest(ModuleStoreTestCase): ) self.assertContains(response, expected_url) + @ddt.data(None, "true", "false") + def test_email_opt_in(self, opt_in_value): + params = { + 'course_id': self.course_id, + 'enrollment_action': 'enroll' + } + + if opt_in_value is not None: + params['email_opt_in'] = opt_in_value + + # Get the login page + response = self.client.get(self.url, params) + + # Verify that the hidden parameter is set correctly + hidden_param = ' % endif +% if email_opt_in: + +% endif +
diff --git a/lms/templates/main.html b/lms/templates/main.html index 24bd8d4870..3dd96b1bec 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -158,8 +158,12 @@ <%def name="login_query()">${ - u"?course_id={0}&enrollment_action={1}".format( + u"?course_id={0}&enrollment_action={1}{email_opt_in}".format( urlquote_plus(course_id), - urlquote_plus(enrollment_action) + urlquote_plus(enrollment_action), + email_opt_in=( + u"&email_opt_in=" + urlquote_plus(email_opt_in) + if email_opt_in else "" + ) ) if course_id and enrollment_action else "" } diff --git a/lms/templates/register.html b/lms/templates/register.html index 9942f807c1..ebaf8f73da 100644 --- a/lms/templates/register.html +++ b/lms/templates/register.html @@ -361,6 +361,10 @@ % endif +% if email_opt_in: + +% endif +