diff --git a/lms/envs/common.py b/lms/envs/common.py index 6be154250b..a5566b2f2e 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -33,6 +33,7 @@ import imp import sys import os +import dealer.git from path import Path as path from warnings import simplefilter from django.utils.translation import ugettext_lazy as _ @@ -3297,3 +3298,12 @@ ACE_CHANNEL_SAILTHRU_API_KEY = None ACE_CHANNEL_SAILTHRU_API_SECRET = None ACE_ROUTING_KEY = LOW_PRIORITY_QUEUE + +EDX_PLATFORM_REVISION = os.environ.get('EDX_PLATFORM_REVISION') +if not EDX_PLATFORM_REVISION: + try: + # Get git revision of the current file + EDX_PLATFORM_REVISION = dealer.git.Backend(path=REPO_ROOT).revision + except TypeError: + # Not a git repository + EDX_PLATFORM_REVISION = 'unknown' diff --git a/openedx/core/djangoapps/schedules/tasks.py b/openedx/core/djangoapps/schedules/tasks.py index b8ae3d5b1d..fbffff2939 100644 --- a/openedx/core/djangoapps/schedules/tasks.py +++ b/openedx/core/djangoapps/schedules/tasks.py @@ -1,4 +1,6 @@ import datetime +from subprocess import check_output, CalledProcessError +from urlparse import urlparse from celery.task import task from django.conf import settings @@ -10,6 +12,8 @@ from edx_ace import ace from edx_ace.message import MessageType, Message from edx_ace.recipient import Recipient from edx_ace.utils.date import deserialize + +from edxmako.shortcuts import marketing_link from openedx.core.djangoapps.schedules.models import Schedule, ScheduleConfig @@ -77,18 +81,47 @@ def _recurring_nudge_schedules_for_hour(target_hour, org_list, exclude_orgs=Fals course_id_str = str(enrollment.course_id) course = enrollment.course - course_root = reverse('course_root', args=[course_id_str]) - - def absolute_url(relative_path): - return u'{}{}'.format(settings.LMS_ROOT_URL, urlquote(relative_path)) + course_root_relative_url = reverse('course_root', args=[course_id_str]) + dashboard_relative_url = reverse('dashboard') template_context = { 'student_name': user.profile.name, 'course_name': course.display_name, - 'course_url': absolute_url(course_root), + 'course_url': absolute_url(course_root_relative_url), + + # Platform information + 'homepage_url': encode_url(marketing_link('ROOT')), + 'dashboard_url': absolute_url(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', {})), # This is used by the bulk email optout policy 'course_id': course_id_str, } yield (user, course.language, template_context) + + +def encode_url(url): + # Sailthru has a bug where URLs that contain "+" characters in their path components are misinterpreted + # when GA instrumentation is enabled. We need to percent-encode the path segments of all URLs that are + # injected into our templates to work around this issue. + parsed_url = urlparse(url) + modified_url = parsed_url._replace(path=urlquote(parsed_url.path)) + return modified_url.geturl() + + +def absolute_url(relative_path): + root = settings.LMS_ROOT_URL.rstrip('/') + relative_path = relative_path.lstrip('/') + return encode_url(u'{root}/{path}'.format(root=root, path=relative_path)) + + +def encode_urls_in_dict(mapping): + urls = {} + for key, value in mapping.iteritems(): + urls[key] = encode_url(value) + return urls diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/base_body.html b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/base_body.html index 66b55a5b85..d5cac9ae7e 100644 --- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/base_body.html +++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/common/base_body.html @@ -1,25 +1,35 @@ {% load i18n %} + + +
+ {% block preview_text %}{% endblock %} +
+ +{# This "View on Web" link must appear in the document before any layout tables so that accessible email clients can #} +{# send the user to a proper web browser which can parse the email correctly. #} + +{# Note {view_url} is not a template variable that is evaluated by the Django template engine. It is evaluated by #} +{# Sailthru when the email is sent. Other email providers would need to replace this variable in the HTML as well. #} +{% trans "View on Web" %} +{# Note this is another late-bound variable #} + + {% get_current_language as LANGUAGE_CODE %}
- -
- {% block preview_text %}{% endblock %} -
- - @@ -132,17 +146,33 @@
- - edX Home Page - - - - - - + {% if social_media_urls.linkedin %} + + {% endif %} + {% if social_media_urls.twitter %} + + {% endif %} + {% if social_media_urls.facebook %} + + {% endif %} + {% if social_media_urls.google_plus %} + + {% endif %} + {% if social_media_urls.reddit %} + + {% endif %}
- - edX on LinkedIn - - - - edX on Twitter - - - - edX on Facebook - - - - edX on Google Plus - - - - edX on Reddit - - + + {% blocktrans %}{{ platform_name }} on LinkedIn{% endblocktrans %} + + + + {% blocktrans %}{{ platform_name }} on Twitter{% endblocktrans %} + + + + {% blocktrans %}{{ platform_name }} on Facebook{% endblocktrans %} + + + + {% blocktrans %}{{ platform_name }} on Google Plus{% endblocktrans %} + + + + {% blocktrans %}{{ platform_name }} on Reddit{% endblocktrans %} + +
+
+ + + + +
+ {# Note that this variable is evaluated by Sailthru, not the Django template engine #} + + {% trans "Unsubscribe from this list" %} + +
+
- - Download the iOS app on the Apple Store - - - Download the Android app on the Google Play Store - + {% if mobile_store_urls.apple %} + + {% trans + + {% endif %} + {% if mobile_store_urls.google %} + + {% trans + + {% endif %}
@@ -154,11 +184,12 @@ @@ -177,3 +208,7 @@ + +{# Debug info that is not user-visible #} + + 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 dc402b6222..6619b83f48 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 @@ -2,19 +2,23 @@ {% load i18n %} {% block preview_text %} - {% blocktrans %} Learning isn't easy - but it's worth it! Complete some problems and learn something new in {{course_name}}. {% endblocktrans %} + {% blocktrans trimmed %} + Keep up the momentum! Many edX learners in {{course_name}} are completing more problems every week, and + participating in the discussion forums. What do you want to do to keep learning? + {% endblocktrans %} {% endblock %} {% block content %}
-

Copyright © 2017 edX, All rights - reserved.

- Our mailing address is:
- 141 Portland St. 9th Floor, Cambridge, MA 02139 + © {% now "Y" %} {{ platform_name }}, {% trans "All rights reserved" %}. +

+

+ {% trans "Our mailing address is" %}:
+ {{ contact_mailing_address }}

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 17db613c2a..53b647b7a5 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 @@ -1,4 +1,7 @@ {% load i18n %} -{% blocktrans %} Keep up the momentum! Many edX learners in {{course_name}} are completing more problems every week, and participating in the discussion forums. What do you want to do to keep learning? {% endblocktrans %} +{% blocktrans trimmed %} + Keep up the momentum! Many edX learners in {{course_name}} are completing more problems every week, and + participating in the discussion forums. What do you want to do to keep learning? +{% endblocktrans %} -{% blocktrans %} Keep learning {% endblocktrans %} <{{course_url}}> \ No newline at end of file +{% trans "Keep learning" %} <{{course_url}}> \ No newline at end of file diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/subject.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/subject.txt index 9935fd1307..942a1b397c 100644 --- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/subject.txt +++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day10/email/subject.txt @@ -1,2 +1,2 @@ {% load i18n %} -{% blocktrans %}What do you want to do to keep learning?{% endblocktrans %} \ No newline at end of file +{% trans "Keep up the momentum!" %} \ No newline at end of file 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 9e90f29e11..370d2dbc60 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 @@ -2,16 +2,24 @@ {% load i18n %} {% block preview_text %} - {% blocktrans %} Learning isn't easy - but it's worth it! Learn something new in {{course_name}}. {% endblocktrans %} + {% blocktrans trimmed %} + Keep learning today. Remember when you enrolled in {{course_name}} on edX.org? We do, and we’re glad + to have you! Come see what everyone is learning. + {% endblocktrans %} {% endblock %} {% block content %}
-

{% blocktrans %} Keep up the momentum! {% endblocktrans %}

+

{% trans "Keep up the momentum!" %}

- {% blocktrans %} Many edX learners in {{course_name}} are - completing more problems every week, and participating in the discussion forums. What do you want to do - to keep learning? {% endblocktrans %} + {% blocktrans trimmed %} + Many edX learners in {{course_name}} are completing more problems every week, and + participating in the discussion forums. What do you want to do to keep learning? + {% endblocktrans %}

@@ -31,7 +35,8 @@ border-left: 16px solid #005686; display: inline-block; "> - {% blocktrans %} Keep learning {% endblocktrans %} + + {% trans "Keep learning" %}

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 d6c59707de..ff31043471 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 @@ -1,4 +1,7 @@ {% load i18n %} -{% blocktrans %} Remember when you enrolled in {{course_name}} on edX.org? We do! Come see what everyone is learning. {% endblocktrans %} +{% blocktrans trimmed %} + Keep learning today. Remember when you enrolled in {{course_name}} on edX.org? We do, and we’re glad + to have you! Come see what everyone is learning. +{% endblocktrans %} -{% blocktrans %} Start learning now {% endblocktrans %} <{{course_url}}> \ No newline at end of file +{% trans "Keep learning" %} <{{course_url}}> \ No newline at end of file diff --git a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/subject.txt b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/subject.txt index 1c625fec86..1fe793f97b 100644 --- a/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/subject.txt +++ b/openedx/core/djangoapps/schedules/templates/schedules/edx_ace/recurringnudge_day3/email/subject.txt @@ -1,3 +1,3 @@ {% load i18n %} -{% blocktrans %} {{course_name}} has started on edX {% endblocktrans %} \ No newline at end of file +{% blocktrans %}Keep learning in {{course_name}}!{% endblocktrans %} \ No newline at end of file
-

{% blocktrans %} Remember when you enrolled in {{course_name}} on edX.org? {% endblocktrans %}

+

{% trans "Keep learning today" %}.

-

{% blocktrans %} We do! Come see what everyone is learning. {% endblocktrans %}

+

+ {% blocktrans trimmed %} + Remember when you enrolled in {{ course_name }} on edX.org? We do, and we’re glad + to have you! Come see what everyone is learning. + {% endblocktrans %} +

@@ -28,7 +36,8 @@ border-left: 16px solid #005686; display: inline-block; "> - {% blocktrans %} Start learning now {% endblocktrans %} + + {% trans "Keep learning" %}