From d3dcca2f493d50575ebb4f2c5f12b8a766511f41 Mon Sep 17 00:00:00 2001
From: Nimisha Asthagiri
Date: Wed, 25 Oct 2017 10:32:55 -0400
Subject: [PATCH 1/2] Schedules: DRY upsell and CTA in templates
---
.../tests/test_send_recurring_nudge.py | 2 +
.../edx_ace/common/return_to_course_cta.html | 27 ++++++++++
.../schedules/edx_ace/common/upsell_cta.html | 26 +++++++++
.../schedules/edx_ace/common/upsell_cta.txt | 10 ++++
.../recurringnudge_day10/email/body.html | 52 ++----------------
.../recurringnudge_day10/email/body.txt | 8 +--
.../recurringnudge_day3/email/body.html | 53 ++-----------------
.../recurringnudge_day3/email/body.txt | 9 +---
.../edx_ace/upgradereminder/email/body.html | 2 -
9 files changed, 74 insertions(+), 115 deletions(-)
create mode 100644 openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/return_to_course_cta.html
create mode 100644 openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.html
create mode 100644 openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.txt
diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
index eb40d4dbbc..effae5c400 100644
--- a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+++ b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
@@ -306,6 +306,8 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
for (_name, (_msg, email), _kwargs) in mock_channel.deliver.mock_calls:
for template in attr.astuple(email):
self.assertNotIn("TEMPLATE WARNING", template)
+ self.assertNotIn("{{", template)
+ self.assertNotIn("}}", template)
def test_user_in_course_with_verified_coursemode_receives_upsell(self):
user = UserFactory.create()
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/return_to_course_cta.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/return_to_course_cta.html
new file mode 100644
index 0000000000..eb6e6b0c0b
--- /dev/null
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/return_to_course_cta.html
@@ -0,0 +1,27 @@
+{% load i18n %}
+
+
+ {# email client support for style sheets is pretty spotty, so we have to inline all of these styles #}
+ 1 %}
+ href="{{ dashboard_url }}"
+ {% else %}
+ href="{{ course_url }}"
+ {% endif %}
+ style="
+ color: #ffffff;
+ text-decoration: none;
+ border-radius: 4px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ background-color: #005686;
+ border-top: 12px solid #005686;
+ border-bottom: 12px solid #005686;
+ border-right: 50px solid #005686;
+ border-left: 50px solid #005686;
+ display: inline-block;
+ ">
+ {# old email clients require the use of the font tag :( #}
+ {{ course_cta_text }}
+
+
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.html
new file mode 100644
index 0000000000..b134529583
--- /dev/null
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.html
@@ -0,0 +1,26 @@
+{% load i18n %}
+
+{% if show_upsell %}
+
+ {% 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 }}.
+ {% endblocktrans %}
+
+
+
+ {% trans "Upgrade Now" %}
+
+
+{% endif %}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.txt
new file mode 100644
index 0000000000..7ee06fa86b
--- /dev/null
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/upsell_cta.txt
@@ -0,0 +1,10 @@
+{% load i18n %}
+
+{% if show_upsell %}
+{% 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 }}.
+
+ Upgrade Now! <{{ upsell_link }}>
+{% endblocktrans %}
+{% endif %}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.html
index 5d103285b4..a4a5eb1342 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.html
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.html
@@ -35,56 +35,10 @@
{% endif %}
-
- {# email client support for style sheets is pretty spotty, so we have to inline all of these styles #}
- 1 %}
- href="{{ dashboard_url }}"
- {% else %}
- href="{{ course_url }}"
- {% endif %}
- style="
- color: #ffffff;
- text-decoration: none;
- border-radius: 4px;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- background-color: #005686;
- border-top: 12px solid #005686;
- border-bottom: 12px solid #005686;
- border-right: 50px solid #005686;
- border-left: 50px solid #005686;
- display: inline-block;
- ">
- {# old email clients require the use of the font tag :( #}
- {% trans "Keep learning" %}
-
-
+ {% trans "Keep learning" as course_cta_text %}
+ {% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
- {% if show_upsell %}
-
- {% 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 }}.
- {% endblocktrans %}
-
-
-
- {% trans "Upgrade Now" %}
-
-
- {% endif %}
+ {% include "schedules/edx_ace/common/upsell_cta.html"%}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.txt
index 96dceea942..f6921804cf 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.txt
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/body.txt
@@ -12,11 +12,5 @@
{% endblocktrans %}
{% trans "Keep learning" %} <{{course_url}}>
{% endif %}
-{% if show_upsell %}
-{% 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 }}.
- Upgrade Now! <{{ upsell_link }}>
-{% endblocktrans %}
-{% endif %}
+{% include "schedules/edx_ace/common/upsell_cta.txt"%}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html
index 40122bb22b..551ba7792b 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.html
@@ -35,55 +35,10 @@
{% endif %}
-
- {# email client support for style sheets is pretty spotty, so we have to inline all of these styles #}
- 1 %}
- href="{{ dashboard_url }}"
- {% else %}
- href="{{ course_url }}"
- {% endif %}
- style="
- color: #ffffff;
- text-decoration: none;
- border-radius: 4px;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- background-color: #005686;
- border-top: 12px solid #005686;
- border-bottom: 12px solid #005686;
- border-right: 50px solid #005686;
- border-left: 50px solid #005686;
- display: inline-block;
- ">
- {# old email clients require the use of the font tag :( #}
- {% trans "Start learning now" %}
-
-
- {% if show_upsell %}
-
- {% 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 }}.
- {% endblocktrans %}
-
-
-
- {% trans "Upgrade Now" %}
-
-
- {% endif %}
+ {% trans "Start learning now" as course_cta_text %}
+ {% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
+
+ {% include "schedules/edx_ace/common/upsell_cta.html"%}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt
index a6704ac851..9a1afec99c 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/body.txt
@@ -16,11 +16,4 @@
{% trans "Start learning now" %} <{{ course_url }}>
{% endif %}
-{% if show_upsell %}
-{% 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 }}.
-
- Upgrade Now! <{{ upsell_link }}>
-{% endblocktrans %}
-{% endif %}
+{% include "schedules/edx_ace/common/upsell_cta.txt"%}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/upgradereminder/email/body.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/upgradereminder/email/body.html
index df23ac1b12..d545d5f24f 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/upgradereminder/email/body.html
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/upgradereminder/email/body.html
@@ -20,8 +20,6 @@
Upgrade by {{ user_schedule_upgrade_deadline_time }}.
{% endblocktrans %}
{% endif %}
- {% blocktrans trimmed %}
- {% endblocktrans %}
{% endblock %}
{% block content %}
From eb3e173dc856fc939634e9954fc6bf0adfcacd33 Mon Sep 17 00:00:00 2001
From: Nimisha Asthagiri
Date: Wed, 25 Oct 2017 10:29:33 -0400
Subject: [PATCH 2/2] Schedules: Course Update support bulleted highlights
---
.../core/djangoapps/schedules/resolvers.py | 8 ++---
.../edx_ace/courseupdate/email/body.html | 31 ++++++-------------
.../edx_ace/courseupdate/email/body.txt | 2 ++
3 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/openedx/core/djangoapps/schedules/resolvers.py b/openedx/core/djangoapps/schedules/resolvers.py
index 340dfbd9b7..f967e6aa1e 100644
--- a/openedx/core/djangoapps/schedules/resolvers.py
+++ b/openedx/core/djangoapps/schedules/resolvers.py
@@ -320,7 +320,7 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
for schedule in schedules:
enrollment = schedule.enrollment
try:
- week_summary = get_course_week_summary(enrollment.course_id, week_num)
+ week_highlights = get_week_highlights(enrollment.course_id, week_num)
except CourseUpdateDoesNotExist:
continue
@@ -333,7 +333,7 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
self.site, reverse('course_root', args=[course_id_str])
),
'week_num': week_num,
- 'week_summary': week_summary,
+ 'week_highlights': week_highlights,
# This is used by the bulk email optout policy
'course_ids': [course_id_str],
@@ -344,9 +344,9 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
@request_cached
-def get_course_week_summary(course_id, week_num):
+def get_week_highlights(course_id, week_num):
if COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_id):
course = modulestore().get_course(course_id)
- return course.week_summary(week_num)
+ return course.highlights_for_week(week_num)
else:
raise CourseUpdateDoesNotExist()
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.html
index e04f056cc3..50ec6bb539 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.html
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.html
@@ -20,31 +20,18 @@
{% blocktrans trimmed %}
Here is what you can look forward to learning this week:
-
{{ week_summary }}
{% endblocktrans %}
+
+ {% for highlight in week_highlights %}
+ - {{ highlight }}
+ {% endfor %}
+
-
-
-
-
- {% trans "Resume your course now" %}
-
-
+ {% trans "Resume your course now" as course_cta_text %}
+ {% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
+
+ {% include "schedules/edx_ace/common/upsell_cta.html"%}
diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.txt
index 3a3109ae7f..e9451139f0 100644
--- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.txt
+++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.txt
@@ -7,3 +7,5 @@ Here is what you can look forward to learning this week:
{{ week_summary }}
{% endblocktrans %}
+
+{% include "schedules/edx_ace/common/upsell_cta.txt"%}