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
2648a639
Commit
2648a639
authored
Jun 06, 2016
by
Awais Jibran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix email opt in list
parent
97816857
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
openedx/core/djangoapps/user_api/management/commands/email_opt_in_list.py
+3
-1
openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py
+24
-1
No files found.
openedx/core/djangoapps/user_api/management/commands/email_opt_in_list.py
View file @
2648a639
...
...
@@ -237,7 +237,9 @@ class Command(BaseCommand):
email
,
full_name
,
course_id
,
is_opted_in
,
pref_set_datetime
=
row
writer
.
writerow
({
"email"
:
email
.
encode
(
'utf-8'
),
"full_name"
:
full_name
.
encode
(
'utf-8'
),
# There should not be a case where users are without full_names. We only need this safe check because
# of ECOM-1995.
"full_name"
:
full_name
.
encode
(
'utf-8'
)
if
full_name
else
''
,
"course_id"
:
course_id
.
encode
(
'utf-8'
),
"is_opted_in_for_email"
:
is_opted_in
if
is_opted_in
else
"True"
,
"preference_set_datetime"
:
pref_set_datetime
if
pref_set_datetime
else
self
.
DEFAULT_DATETIME_STR
,
...
...
openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py
View file @
2648a639
...
...
@@ -10,6 +10,7 @@ from unittest import skipUnless
import
ddt
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core.management.base
import
CommandError
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -257,6 +258,24 @@ class EmailOptInListTest(ModuleStoreTestCase):
with
self
.
assertRaisesRegexp
(
CommandError
,
"^File already exists"
):
email_opt_in_list
.
Command
()
.
handle
(
temp_file
.
name
,
self
.
TEST_ORG
)
def
test_no_user_profile
(
self
):
"""
Tests that command does not break if a user has no profile.
"""
self
.
_create_courses_and_enrollments
((
self
.
TEST_ORG
,
True
))
self
.
_set_opt_in_pref
(
self
.
user
,
self
.
TEST_ORG
,
True
)
# Remove the user profile, and re-fetch user
self
.
assertTrue
(
hasattr
(
self
.
user
,
'profile'
))
self
.
user
.
profile
.
delete
()
user
=
User
.
objects
.
get
(
id
=
self
.
user
.
id
)
# Test that user do not have profile
self
.
assertFalse
(
hasattr
(
user
,
'profile'
))
output
=
self
.
_run_command
(
self
.
TEST_ORG
)
self
.
_assert_output
(
output
,
(
user
,
self
.
courses
[
0
]
.
id
,
True
))
def
_create_courses_and_enrollments
(
self
,
*
args
):
"""Create courses and enrollments.
...
...
@@ -393,7 +412,11 @@ class EmailOptInListTest(ModuleStoreTestCase):
for
user
,
course_id
,
opt_in_pref
in
args
:
self
.
assertIn
({
"email"
:
user
.
email
.
encode
(
'utf-8'
),
"full_name"
:
user
.
profile
.
name
.
encode
(
'utf-8'
),
"full_name"
:
(
user
.
profile
.
name
.
encode
(
'utf-8'
)
if
hasattr
(
user
,
'profile'
)
else
''
),
"course_id"
:
unicode
(
course_id
)
.
encode
(
'utf-8'
),
"is_opted_in_for_email"
:
unicode
(
opt_in_pref
),
"preference_set_datetime"
:
(
...
...
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