Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
23a51a65
Commit
23a51a65
authored
Dec 08, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add email opt in to old login and register pages
parent
f561e79a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
2 deletions
+71
-2
common/djangoapps/student/tests/test_login_registration_forms.py
+53
-0
common/djangoapps/student/views.py
+4
-0
lms/templates/login.html
+4
-0
lms/templates/main.html
+6
-2
lms/templates/register.html
+4
-0
No files found.
common/djangoapps/student/tests/test_login_registration_forms.py
View file @
23a51a65
"""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
=
'<input type="hidden" name="email_opt_in" value="{val}"'
.
format
(
val
=
opt_in_value
)
if
opt_in_value
is
not
None
:
self
.
assertContains
(
response
,
hidden_param
)
else
:
self
.
assertNotContains
(
response
,
hidden_param
)
@ddt.ddt
@override_settings
(
MODULESTORE
=
MODULESTORE_CONFIG
)
...
...
@@ -182,3 +206,32 @@ class RegisterFormTest(ModuleStoreTestCase):
redirect_url
=
reverse
(
"shoppingcart.views.show_cart"
)
)
self
.
assertContains
(
response
,
expected_url
)
@ddt.data
(
None
,
"true"
,
"false"
)
def
test_email_opt_in
(
self
,
opt_in_value
):
params
=
OrderedDict
()
params
[
'course_id'
]
=
self
.
course_id
params
[
'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
=
'<input type="hidden" name="email_opt_in" value="{val}"'
.
format
(
val
=
opt_in_value
)
if
opt_in_value
is
not
None
:
self
.
assertContains
(
response
,
hidden_param
)
else
:
self
.
assertNotContains
(
response
,
hidden_param
)
# Verify that the login link preserves the querystring params
login_link
=
u"{url}?{params}"
.
format
(
url
=
reverse
(
'signin_user'
),
params
=
urllib
.
urlencode
(
params
)
)
self
.
assertContains
(
response
,
login_link
)
common/djangoapps/student/views.py
View file @
23a51a65
...
...
@@ -364,8 +364,10 @@ def signin_user(request):
return
redirect
(
reverse
(
'dashboard'
))
course_id
=
request
.
GET
.
get
(
'course_id'
)
email_opt_in
=
request
.
GET
.
get
(
'email_opt_in'
)
context
=
{
'course_id'
:
course_id
,
'email_opt_in'
:
email_opt_in
,
'enrollment_action'
:
request
.
GET
.
get
(
'enrollment_action'
),
# Bool injected into JS to submit form if we're inside a running third-
# party auth pipeline; distinct from the actual instance of the running
...
...
@@ -394,9 +396,11 @@ def register_user(request, extra_context=None):
return
external_auth
.
views
.
redirect_with_get
(
'root'
,
request
.
GET
)
course_id
=
request
.
GET
.
get
(
'course_id'
)
email_opt_in
=
request
.
GET
.
get
(
'email_opt_in'
)
context
=
{
'course_id'
:
course_id
,
'email_opt_in'
:
email_opt_in
,
'email'
:
''
,
'enrollment_action'
:
request
.
GET
.
get
(
'enrollment_action'
),
'name'
:
''
,
...
...
lms/templates/login.html
View file @
23a51a65
...
...
@@ -198,6 +198,10 @@
<input
type=
"hidden"
name=
"course_id"
value=
"${course_id | h}"
/>
% endif
% if email_opt_in:
<input
type=
"hidden"
name=
"email_opt_in"
value=
"${email_opt_in | h}"
/>
% endif
<div
class=
"form-actions"
>
<button
name=
"submit"
type=
"submit"
id=
"submit"
class=
"action action-primary action-update login-button"
></button>
</div>
...
...
lms/templates/main.html
View file @
23a51a65
...
...
@@ -158,8 +158,12 @@
</html>
<
%
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 ""
}
</
%
def>
lms/templates/register.html
View file @
23a51a65
...
...
@@ -361,6 +361,10 @@
<input
type=
"hidden"
name=
"course_id"
value=
"${course_id | h}"
/>
% endif
% if email_opt_in:
<input
type=
"hidden"
name=
"email_opt_in"
value=
"${email_opt_in | h }"
/>
% endif
<div
class=
"form-actions"
>
<button
name=
"submit"
type=
"submit"
id=
"submit"
class=
"action action-primary action-update register-button"
>
${_('Register')}
<span
class=
"orn-plus"
>
+
</span>
${_('Create My Account')}
</button>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment