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
5e41a34d
Commit
5e41a34d
authored
Dec 03, 2014
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refrain from setting email opt-in preference when checkbox is missing
parent
db9bb20c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
common/djangoapps/student/tests/test_enrollment.py
+8
-2
common/djangoapps/student/views.py
+4
-2
lms/templates/courseware/mktg_course_about.html
+30
-19
No files found.
common/djangoapps/student/tests/test_enrollment.py
View file @
5e41a34d
...
@@ -110,10 +110,13 @@ class EnrollmentTest(ModuleStoreTestCase):
...
@@ -110,10 +110,13 @@ class EnrollmentTest(ModuleStoreTestCase):
@ddt.data
(
@ddt.data
(
([],
'true'
),
([],
'true'
),
([],
'false'
),
([],
'false'
),
([],
None
),
([
'honor'
,
'verified'
],
'true'
),
([
'honor'
,
'verified'
],
'true'
),
([
'honor'
,
'verified'
],
'false'
),
([
'honor'
,
'verified'
],
'false'
),
([
'honor'
,
'verified'
],
None
),
([
'professional'
],
'true'
),
([
'professional'
],
'true'
),
([
'professional'
],
'false'
),
([
'professional'
],
'false'
),
([
'professional'
],
None
),
)
)
@ddt.unpack
@ddt.unpack
def
test_enroll_with_email_opt_in
(
self
,
course_modes
,
email_opt_in
,
mock_update_email_opt_in
):
def
test_enroll_with_email_opt_in
(
self
,
course_modes
,
email_opt_in
,
mock_update_email_opt_in
):
...
@@ -129,8 +132,11 @@ class EnrollmentTest(ModuleStoreTestCase):
...
@@ -129,8 +132,11 @@ class EnrollmentTest(ModuleStoreTestCase):
self
.
_change_enrollment
(
'enroll'
,
email_opt_in
=
email_opt_in
)
self
.
_change_enrollment
(
'enroll'
,
email_opt_in
=
email_opt_in
)
# Verify that the profile API has been called as expected
# Verify that the profile API has been called as expected
opt_in
=
email_opt_in
==
'true'
if
email_opt_in
is
not
None
:
mock_update_email_opt_in
.
assert_called_once_with
(
self
.
USERNAME
,
self
.
course
.
org
,
opt_in
)
opt_in
=
email_opt_in
==
'true'
mock_update_email_opt_in
.
assert_called_once_with
(
self
.
USERNAME
,
self
.
course
.
org
,
opt_in
)
else
:
self
.
assertFalse
(
mock_update_email_opt_in
.
called
)
def
test_user_not_authenticated
(
self
):
def
test_user_not_authenticated
(
self
):
# Log out, so we're no longer authenticated
# Log out, so we're no longer authenticated
...
...
common/djangoapps/student/views.py
View file @
5e41a34d
...
@@ -776,8 +776,10 @@ def try_change_enrollment(request):
...
@@ -776,8 +776,10 @@ def try_change_enrollment(request):
def
_update_email_opt_in
(
request
,
username
,
org
):
def
_update_email_opt_in
(
request
,
username
,
org
):
"""Helper function used to hit the profile API if email opt-in is enabled."""
"""Helper function used to hit the profile API if email opt-in is enabled."""
email_opt_in
=
request
.
POST
.
get
(
'email_opt_in'
)
==
'true'
email_opt_in
=
request
.
POST
.
get
(
'email_opt_in'
)
profile_api
.
update_email_opt_in
(
username
,
org
,
email_opt_in
)
if
email_opt_in
is
not
None
:
email_opt_in_boolean
=
email_opt_in
==
'true'
profile_api
.
update_email_opt_in
(
username
,
org
,
email_opt_in_boolean
)
@require_POST
@require_POST
...
...
lms/templates/courseware/mktg_course_about.html
View file @
5e41a34d
...
@@ -11,19 +11,30 @@
...
@@ -11,19 +11,30 @@
<
%
block
name=
"bodyclass"
>
view-iframe-content view-partial-mktgregister
</
%
block>
<
%
block
name=
"bodyclass"
>
view-iframe-content view-partial-mktgregister
</
%
block>
<
%
block
name=
"js_extra"
>
<
%
block
name=
"js_extra"
>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
(
function
()
{
(
function
()
{
$
(
".register"
).
click
(
function
(
event
)
{
$
(
".register"
).
click
(
function
(
event
)
{
if
(
!
$
(
"#email-opt-in"
).
prop
(
"checked"
)
)
{
var
el
=
$
(
"input[name='email_opt_in']"
),
$
(
"input[name='email_opt_in']"
).
val
(
"false"
);
emailOptIn
,
}
currentHref
;
// Check if the email opt-in checkbox is missing
if
(
$
(
"#email-opt-in"
).
length
==
0
)
{
// Remove the corresponding hidden form element
el
.
remove
();
}
else
{
// Check if the email opt-in checkbox is not checked
if
(
!
$
(
"#email-opt-in"
).
prop
(
"checked"
)
)
{
// Set the value of the corresponding hidden form element
el
.
val
(
"false"
);
}
var
email_opt_in
=
$
(
"input[name='email_opt_in']"
).
val
(),
emailOptIn
=
el
.
val
();
current_href
=
$
(
"a.register"
).
attr
(
"href"
);
currentHref
=
$
(
"a.register"
).
attr
(
"href"
);
if
(
current_href
)
{
if
(
currentHref
)
{
$
(
"a.register"
).
attr
(
"href"
,
current_href
+
"&email_opt_in="
+
email_opt_in
)
$
(
"a.register"
).
attr
(
"href"
,
currentHref
+
"&email_opt_in="
+
emailOptIn
);
}
}
}
$
(
"#class_enroll_form"
).
submit
();
$
(
"#class_enroll_form"
).
submit
();
...
@@ -31,6 +42,8 @@
...
@@ -31,6 +42,8 @@
});
});
$
(
'#class_enroll_form'
).
on
(
'ajax:complete'
,
function
(
event
,
xhr
)
{
$
(
'#class_enroll_form'
).
on
(
'ajax:complete'
,
function
(
event
,
xhr
)
{
var
emailOptIn
=
''
;
if
(
xhr
.
status
==
200
)
{
if
(
xhr
.
status
==
200
)
{
if
(
xhr
.
responseText
!=
""
)
{
if
(
xhr
.
responseText
!=
""
)
{
window
.
top
.
location
.
href
=
xhr
.
responseText
;
window
.
top
.
location
.
href
=
xhr
.
responseText
;
...
@@ -39,13 +52,14 @@
...
@@ -39,13 +52,14 @@
window
.
top
.
location
.
href
=
"${reverse('dashboard')}"
;
window
.
top
.
location
.
href
=
"${reverse('dashboard')}"
;
}
}
}
else
if
(
xhr
.
status
==
403
)
{
}
else
if
(
xhr
.
status
==
403
)
{
var
email_opt_in
=
$
(
"input[name='email_opt_in']"
).
val
();
// Check if the email opt-in checkbox is present
if
(
$
(
"#email-opt-in"
).
length
!=
0
)
{
emailOptIn
=
'&email_opt_in='
+
$
(
"input[name='email_opt_in']"
).
val
();
}
<%
href_url
=
'accounts_login'
if
settings
.
FEATURES
.
get
(
"ENABLE_COMBINED_LOGIN_REGISTRATION"
)
else
'register_user'
%>
##
Ugh
.
##
Ugh
.
%
if
settings
.
FEATURES
.
get
(
"ENABLE_COMBINED_LOGIN_REGISTRATION"
):
window
.
top
.
location
.
href
=
$
(
"a.register"
).
attr
(
"href"
)
||
"${reverse(href_url)}?course_id=${course.id | u}&enrollment_action=enroll"
+
emailOptIn
;
window
.
top
.
location
.
href
=
$
(
"a.register"
).
attr
(
"href"
)
||
"${reverse('accounts_login')}?course_id=${course.id | u}&enrollment_action=enroll&email_opt_in="
+
email_opt_in
;
%
else
:
window
.
top
.
location
.
href
=
$
(
"a.register"
).
attr
(
"href"
)
||
"${reverse('register_user')}?course_id=${course.id | u}&enrollment_action=enroll&email_opt_in="
+
email_opt_in
;
%
endif
}
else
{
}
else
{
$
(
'#register_error'
).
html
(
$
(
'#register_error'
).
html
(
(
xhr
.
responseText
?
xhr
.
responseText
:
"${_("
An
error
occurred
.
Please
try
again
later
.
")}"
)
(
xhr
.
responseText
?
xhr
.
responseText
:
"${_("
An
error
occurred
.
Please
try
again
later
.
")}"
)
...
@@ -70,11 +84,8 @@
...
@@ -70,11 +84,8 @@
%elif allow_registration:
%elif allow_registration:
<a
class=
"action action-register register ${'has-option-verified' if len(course_modes) > 1 else ''}"
<a
class=
"action action-register register ${'has-option-verified' if len(course_modes) > 1 else ''}"
%
if
not
user
.
is_authenticated
()
:
%
if
not
user
.
is_authenticated
()
:
%
if
settings
.
FEATURES
.
get
("
ENABLE_COMBINED_LOGIN_REGISTRATION
")
:
<%
href_url =
'accounts_login'
if
settings
.
FEATURES
.
get
("
ENABLE_COMBINED_LOGIN_REGISTRATION
")
else
'
register_user
'
%
>
href=
"${reverse('accounts_login')}?course_id=${course.id | u}&enrollment_action=enroll"
href="${reverse(href_url)}?course_id=${course.id | u}
&
enrollment_action=enroll"
%
else:
href=
"${reverse('register_user')}?course_id=${course.id | u}&enrollment_action=enroll"
%
endif
%endif
%endif
>${_("Enroll in")}
<strong>
${course.display_number_with_default | h}
</strong>
>${_("Enroll in")}
<strong>
${course.display_number_with_default | h}
</strong>
%if len(course_modes) > 1:
%if len(course_modes) > 1:
...
...
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