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
0495d70b
Commit
0495d70b
authored
Aug 29, 2017
by
Uzair Rasheed
Committed by
GitHub
Aug 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15890 from edx/LEARNER-1466/WL-email
Fix email will not sent to white-label users
parents
3a65cedf
1aea33ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
lms/djangoapps/email_marketing/tasks.py
+13
-2
lms/djangoapps/email_marketing/tests/test_signals.py
+17
-0
No files found.
lms/djangoapps/email_marketing/tasks.py
View file @
0495d70b
...
@@ -95,7 +95,7 @@ def update_user(self, sailthru_vars, email, site=None, new_user=False):
...
@@ -95,7 +95,7 @@ def update_user(self, sailthru_vars, email, site=None, new_user=False):
return
return
# if new user, send welcome email
# if new user, send welcome email
if
new_user
and
email_config
.
sailthru_welcome_template
:
if
new_user
and
email_config
.
sailthru_welcome_template
and
is_default_site
(
site
)
:
scheduled_datetime
=
datetime
.
utcnow
()
+
timedelta
(
seconds
=
email_config
.
welcome_email_send_delay
)
scheduled_datetime
=
datetime
.
utcnow
()
+
timedelta
(
seconds
=
email_config
.
welcome_email_send_delay
)
try
:
try
:
sailthru_response
=
sailthru_client
.
api_post
(
sailthru_response
=
sailthru_client
.
api_post
(
...
@@ -120,6 +120,17 @@ def update_user(self, sailthru_vars, email, site=None, new_user=False):
...
@@ -120,6 +120,17 @@ def update_user(self, sailthru_vars, email, site=None, new_user=False):
max_retries
=
email_config
.
sailthru_max_retries
)
max_retries
=
email_config
.
sailthru_max_retries
)
def
is_default_site
(
site
):
"""
Checks whether the site is a default site or a white-label
Args:
site: A dict containing the site info
Returns:
Boolean
"""
return
not
site
or
site
.
get
(
'id'
)
==
settings
.
SITE_ID
# pylint: disable=not-callable
# pylint: disable=not-callable
@task
(
bind
=
True
,
default_retry_delay
=
3600
,
max_retries
=
24
)
@task
(
bind
=
True
,
default_retry_delay
=
3600
,
max_retries
=
24
)
def
update_user_email
(
self
,
new_email
,
old_email
):
def
update_user_email
(
self
,
new_email
,
old_email
):
...
@@ -184,7 +195,7 @@ def _get_or_create_user_list_for_site(sailthru_client, site=None, default_list_n
...
@@ -184,7 +195,7 @@ def _get_or_create_user_list_for_site(sailthru_client, site=None, default_list_n
:param: default_list_name
:param: default_list_name
:return: list name if exists or created else return None
:return: list name if exists or created else return None
"""
"""
if
site
and
site
.
get
(
'id'
)
!=
settings
.
SITE_ID
:
if
not
is_default_site
(
site
)
:
list_name
=
site
.
get
(
'domain'
,
''
)
.
replace
(
"."
,
"_"
)
+
"_user_list"
list_name
=
site
.
get
(
'domain'
,
''
)
.
replace
(
"."
,
"_"
)
+
"_user_list"
else
:
else
:
list_name
=
default_list_name
list_name
=
default_list_name
...
...
lms/djangoapps/email_marketing/tests/test_signals.py
View file @
0495d70b
...
@@ -191,6 +191,23 @@ class EmailMarketingTests(TestCase):
...
@@ -191,6 +191,23 @@ class EmailMarketingTests(TestCase):
self
.
assertEquals
(
userparms
[
'template'
],
"Welcome"
)
self
.
assertEquals
(
userparms
[
'template'
],
"Welcome"
)
self
.
assertEquals
(
userparms
[
'schedule_time'
],
expected_schedule
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
))
self
.
assertEquals
(
userparms
[
'schedule_time'
],
expected_schedule
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
))
@patch
(
'email_marketing.tasks.log.error'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_post'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_get'
)
def
test_email_not_sent_to_white_label
(
self
,
mock_sailthru_get
,
mock_sailthru_post
,
mock_log_error
):
"""
tests that welcome email is not sent to the white-label site learner
"""
white_label_site
=
Site
.
objects
.
create
(
domain
=
'testwhitelabel.com'
,
name
=
'White Label'
)
site_dict
=
{
'id'
:
white_label_site
.
id
,
'domain'
:
white_label_site
.
domain
,
'name'
:
white_label_site
.
name
}
mock_sailthru_post
.
return_value
=
SailthruResponse
(
JsonResponse
({
'ok'
:
True
}))
mock_sailthru_get
.
return_value
=
SailthruResponse
(
JsonResponse
({
'lists'
:
[{
'name'
:
'new list'
}],
'ok'
:
True
}))
update_user
.
delay
(
{
'gender'
:
'm'
,
'username'
:
'test'
,
'activated'
:
1
},
TEST_EMAIL
,
site_dict
,
new_user
=
True
)
self
.
assertFalse
(
mock_log_error
.
called
)
self
.
assertNotEqual
(
mock_sailthru_post
.
call_args
[
0
][
0
],
"send"
)
@patch
(
'email_marketing.tasks.SailthruClient.api_post'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_post'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_get'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_get'
)
def
test_add_user_list_existing_domain
(
self
,
mock_sailthru_get
,
mock_sailthru_post
):
def
test_add_user_list_existing_domain
(
self
,
mock_sailthru_get
,
mock_sailthru_post
):
...
...
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