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
f8d41b97
Commit
f8d41b97
authored
Sep 25, 2017
by
castellanese
Committed by
sandroroux
Oct 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Differentiated emails - unverified users receive email with upsell button.
parent
d38428ea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
31 deletions
+108
-31
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+1
-1
openedx/core/djangoapps/schedules/tasks.py
+63
-21
openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html
+37
-9
openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt
+7
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
f8d41b97
...
@@ -233,7 +233,7 @@ class TestSendRecurringNudge(CacheIsolationTestCase):
...
@@ -233,7 +233,7 @@ class TestSendRecurringNudge(CacheIsolationTestCase):
patch_channels
(
self
,
[
mock_channel
])
patch_channels
(
self
,
[
mock_channel
])
sent_messages
=
[]
sent_messages
=
[]
templates_override
=
deepcopy
(
settings
.
TEMPLATES
)
templates_override
=
deepcopy
(
settings
.
TEMPLATES
)
templates_override
[
0
][
'OPTIONS'
][
'string_if_invalid'
]
=
"TEMPLATE WARNING - MISSING VARIABLE [
%
s]"
templates_override
[
0
][
'OPTIONS'
][
'string_if_invalid'
]
=
"TEMPLATE WARNING - MISSING VARIABLE [
%
s]"
with
self
.
settings
(
TEMPLATES
=
templates_override
):
with
self
.
settings
(
TEMPLATES
=
templates_override
):
...
...
openedx/core/djangoapps/schedules/tasks.py
View file @
f8d41b97
...
@@ -18,6 +18,7 @@ from edx_ace.message import Message
...
@@ -18,6 +18,7 @@ from edx_ace.message import Message
from
edx_ace.recipient
import
Recipient
from
edx_ace.recipient
import
Recipient
from
edx_ace.utils.date
import
deserialize
from
edx_ace.utils.date
import
deserialize
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
lms.djangoapps.experiments.utils
import
check_and_get_upgrade_link
from
edxmako.shortcuts
import
marketing_link
from
edxmako.shortcuts
import
marketing_link
from
openedx.core.djangoapps.schedules.message_type
import
ScheduleMessageType
from
openedx.core.djangoapps.schedules.message_type
import
ScheduleMessageType
...
@@ -105,6 +106,40 @@ def _recurring_nudge_schedule_send(site_id, msg_str):
...
@@ -105,6 +106,40 @@ def _recurring_nudge_schedule_send(site_id, msg_str):
# TODO: delete once _recurring_nudge_schedules_for_bin is fully rolled out
# TODO: delete once _recurring_nudge_schedules_for_bin is fully rolled out
def
_recurring_nudge_schedules_for_hour
(
site
,
target_hour
,
org_list
,
exclude_orgs
=
False
):
def
_recurring_nudge_schedules_for_hour
(
site
,
target_hour
,
org_list
,
exclude_orgs
=
False
):
users
,
schedules
=
_gather_users_and_schedules_for_target_hour
(
target_hour
,
org_list
,
exclude_orgs
)
dashboard_relative_url
=
reverse
(
'dashboard'
)
for
(
user
,
user_schedules
)
in
groupby
(
schedules
,
lambda
s
:
s
.
enrollment
.
user
):
user_schedules
=
list
(
user_schedules
)
course_id_strs
=
[
str
(
schedule
.
enrollment
.
course_id
)
for
schedule
in
user_schedules
]
first_schedule
=
user_schedules
[
0
]
template_context
=
{
'student_name'
:
user
.
profile
.
name
,
'course_name'
:
first_schedule
.
enrollment
.
course
.
display_name
,
'course_url'
:
absolute_url
(
site
,
reverse
(
'course_root'
,
args
=
[
str
(
first_schedule
.
enrollment
.
course_id
)])),
# This is used by the bulk email optout policy
'course_ids'
:
course_id_strs
,
# Platform information
'homepage_url'
:
encode_url
(
marketing_link
(
'ROOT'
)),
'dashboard_url'
:
absolute_url
(
site
,
dashboard_relative_url
),
'template_revision'
:
settings
.
EDX_PLATFORM_REVISION
,
'platform_name'
:
settings
.
PLATFORM_NAME
,
'contact_mailing_address'
:
settings
.
CONTACT_MAILING_ADDRESS
,
'social_media_urls'
:
encode_urls_in_dict
(
getattr
(
settings
,
'SOCIAL_MEDIA_FOOTER_URLS'
,
{})),
'mobile_store_urls'
:
encode_urls_in_dict
(
getattr
(
settings
,
'MOBILE_STORE_URLS'
,
{})),
}
# Information for including upsell messaging in template.
_add_upsell_button_to_email_template
(
user
,
first_schedule
,
template_context
)
yield
(
user
,
first_schedule
.
enrollment
.
course
.
language
,
template_context
)
def
_gather_users_and_schedules_for_target_hour
(
target_hour
,
org_list
,
exclude_orgs
):
beginning_of_day
=
target_hour
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
)
beginning_of_day
=
target_hour
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
)
users
=
User
.
objects
.
filter
(
users
=
User
.
objects
.
filter
(
courseenrollment__schedule__start__gte
=
beginning_of_day
,
courseenrollment__schedule__start__gte
=
beginning_of_day
,
...
@@ -138,32 +173,39 @@ def _recurring_nudge_schedules_for_hour(site, target_hour, org_list, exclude_org
...
@@ -138,32 +173,39 @@ def _recurring_nudge_schedules_for_hour(site, target_hour, org_list, exclude_org
LOG
.
debug
(
'Scheduled Nudge: Query =
%
r'
,
schedules
.
query
.
sql_with_params
())
LOG
.
debug
(
'Scheduled Nudge: Query =
%
r'
,
schedules
.
query
.
sql_with_params
())
dashboard_relative_url
=
reverse
(
'dashboard'
)
return
users
,
schedules
for
(
user
,
user_schedules
)
in
groupby
(
schedules
,
lambda
s
:
s
.
enrollment
.
user
):
user_schedules
=
list
(
user_schedules
)
course_id_strs
=
[
str
(
schedule
.
enrollment
.
course_id
)
for
schedule
in
user_schedules
]
first_schedule
=
user_schedules
[
0
]
def
_should_user_be_upsold
(
enrollment
):
template_context
=
{
enrollment_mode
=
None
'student_name'
:
user
.
profile
.
name
,
is_active
=
None
'course_name'
:
first_schedule
.
enrollment
.
course
.
display_name
,
if
enrollment
:
'course_url'
:
absolute_url
(
site
,
reverse
(
'course_root'
,
args
=
[
str
(
first_schedule
.
enrollment
.
course_id
)])),
enrollment_mode
=
enrollment
.
mode
is_active
=
enrollment
.
is_active
# This is used by the bulk email optout policy
# Return `true` if user is not enrolled in course
'course_ids'
:
course_id_strs
,
if
enrollment_mode
is
None
and
is_active
is
None
:
return
True
# Platform information
# Show the summary if user enrollment is in which allow user to upsell
'homepage_url'
:
encode_url
(
marketing_link
(
'ROOT'
)),
return
is_active
and
enrollment_mode
in
[
"Verified"
,
"Professional"
]
'dashboard_url'
:
absolute_url
(
site
,
dashboard_relative_url
),
'template_revision'
:
settings
.
EDX_PLATFORM_REVISION
,
'platform_name'
:
settings
.
PLATFORM_NAME
,
def
_add_upsell_button_to_email_template
(
a_user
,
a_schedule
,
template_context
):
'contact_mailing_address'
:
settings
.
CONTACT_MAILING_ADDRESS
,
show_upsell
=
_should_user_be_upsold
(
a_schedule
.
enrollment
)
'social_media_urls'
:
encode_urls_in_dict
(
getattr
(
settings
,
'SOCIAL_MEDIA_FOOTER_URLS'
,
{})),
# Check and upgrade link performs a query on CourseMode, which is triggering failures in
'mobile_store_urls'
:
encode_urls_in_dict
(
getattr
(
settings
,
'MOBILE_STORE_URLS'
,
{})),
# test_send_recurring_nudge.py
}
upgrade_data
=
check_and_get_upgrade_link
(
a_user
,
a_schedule
.
enrollment
.
course_id
)
yield
(
user
,
first_schedule
.
enrollment
.
course
.
language
,
template_context
)
upsell_link
=
''
if
upgrade_data
:
upsell_link
=
upgrade_data
.
link
template_context
[
'show_upsell'
]
=
show_upsell
template_context
[
'upsell_link'
]
=
upsell_link
template_context
[
'user_schedule_upgrade_deadline_time'
]
=
upgrade_data
.
date
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
...
...
openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html
View file @
f8d41b97
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
</p>
</p>
<p>
<p>
<!-- email client support for style sheets is pretty spotty, so we have to inline all of these styles -->
{# email client support for style sheets is pretty spotty, so we have to inline all of these styles #}
<a
<a
{%
if
course_ids
|
length
>
1 %}
{%
if
course_ids
|
length
>
1 %}
href="{{ dashboard_url }}"
href="{{ dashboard_url }}"
...
@@ -46,20 +46,48 @@
...
@@ -46,20 +46,48 @@
style="
style="
color: #ffffff;
color: #ffffff;
text-decoration: none;
text-decoration: none;
border-radius:
4px
;
border-radius:
.3rem
;
-webkit-border-radius:
4px
;
-webkit-border-radius:
.3rem
;
-moz-border-radius:
4px
;
-moz-border-radius:
.3rem
;
background-color: #005686;
background-color: #005686;
border-top:
10px
solid #005686;
border-top:
.15rem
solid #005686;
border-bottom:
10px
solid #005686;
border-bottom:
.15rem
solid #005686;
border-right:
16px
solid #005686;
border-right:
.15rem
solid #005686;
border-left:
16px
solid #005686;
border-left:
.15rem
solid #005686;
display: inline-block;
display: inline-block;
padding: 1rem 5rem;
">
">
<!-- old email clients require the use of the font tag :( -->
{# old email clients require the use of the font tag :( #}
<font
color=
"#ffffff"
><b>
{% trans "Start learning now" %}
</b></font>
<font
color=
"#ffffff"
><b>
{% trans "Start learning now" %}
</b></font>
</a>
</a>
</p>
</p>
{% if show_upsell %}
<p>
{% blocktrans trimmed %}
Don't miss the opportunity to highlight your new knowledge and skills by earning a verified
certificate. Upgrade by {{ user_schedule_upgrade_deadline_time|date:"l, F dS, Y" }}.
{% endblocktrans %}
</p>
<p>
<a
href=
"{{ upsell_link }}"
style=
"
color: #1e8142;
text-decoration: none;
border-radius: .3rem;
-webkit-border-radius: .3rem;
-moz-border-radius: .3rem;
background-color: #FFFFFF;
border-top: .15rem solid #1e8142;
border-bottom: .15rem solid #1e8142;
border-right: .15rem solid #1e8142;
border-left: .15rem solid #1e8142;
display: inline-block;
padding: 1rem 6.1rem;
"
>
<font
color=
"#1e8142"
><b>
{% trans "Upgrade Now" %}
</b></font>
</a>
</p>
{% endif %}
</td>
</td>
</tr>
</tr>
</table>
</table>
...
...
openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt
View file @
f8d41b97
...
@@ -15,3 +15,10 @@
...
@@ -15,3 +15,10 @@
{% trans "Start learning now" %} <{{ course_url }}>
{% trans "Start learning now" %} <{{ course_url }}>
{% endif %}
{% endif %}
{% blocktrans trimmed %}
Don't miss the opportunity to highlight your new knowledge and skills by earning a verified
certificate. Upgrade by {{ user_schedule_upgrade_deadline_time|date:"l, F dS, Y" }}.
Upgrade Now! <{{ upsell_link }}>
{% endblocktrans %}
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