Commit 0ea5a495 by Awais Committed by Awais Qureshi

Emails templates for studio instance creation.

Ecom-6041
parent 7230c386
...@@ -267,7 +267,7 @@ class UpdateCourseKeyViewTests(TestCase): ...@@ -267,7 +267,7 @@ class UpdateCourseKeyViewTests(TestCase):
self.assert_email_sent( self.assert_email_sent(
reverse('publisher:publisher_course_run_detail', kwargs={'pk': self.course_run.id}), reverse('publisher:publisher_course_run_detail', kwargs={'pk': self.course_run.id}),
'Studio instance created', 'Studio instance created',
'Studio instance created for the following course run' 'EdX has created a Studio instance for '
) )
def assert_course_key_and_changed_by(self, lms_course_id=None, changed_by=None): def assert_course_key_and_changed_by(self, lms_course_id=None, changed_by=None):
......
...@@ -6,6 +6,7 @@ from django.core.mail.message import EmailMultiAlternatives ...@@ -6,6 +6,7 @@ from django.core.mail.message import EmailMultiAlternatives
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.template.loader import get_template from django.template.loader import get_template
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from course_discovery.apps.publisher.choices import PublisherUserRole
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -64,11 +65,20 @@ def send_email_for_studio_instance_created(course_run): ...@@ -64,11 +65,20 @@ def send_email_for_studio_instance_created(course_run):
to_addresses = course_run.course.get_course_users_emails() to_addresses = course_run.course.get_course_users_emails()
from_address = settings.PUBLISHER_FROM_EMAIL from_address = settings.PUBLISHER_FROM_EMAIL
course_user_roles = course_run.course.course_user_roles.all()
course_team = course_user_roles.filter(role=PublisherUserRole.CourseTeam).first()
partner_coordinator = course_user_roles.filter(role=PublisherUserRole.PartnerCoordinator).first()
context = { context = {
'course_run': course_run, 'course_run': course_run,
'course_run_page_url': 'https://{host}{path}'.format( 'course_run_page_url': 'https://{host}{path}'.format(
host=Site.objects.get_current().domain.strip('/'), path=object_path host=Site.objects.get_current().domain.strip('/'), path=object_path
) ),
'course_name': course_run.course.title,
'from_address': from_address,
'course_team_name': course_team.user.full_name if course_team else '',
'partner_coordinator_name': partner_coordinator.user.full_name if partner_coordinator else '',
'contact_us_email': partner_coordinator.user.email if partner_coordinator else ''
} }
txt_template_path = 'publisher/email/studio_instance_created.txt' txt_template_path = 'publisher/email/studio_instance_created.txt'
......
...@@ -150,6 +150,11 @@ class StudioInstanceCreatedEmailTests(TestCase): ...@@ -150,6 +150,11 @@ class StudioInstanceCreatedEmailTests(TestCase):
course=self.course_run.course, role=PublisherUserRole.PartnerCoordinator, user=self.user course=self.course_run.course, role=PublisherUserRole.PartnerCoordinator, user=self.user
) )
self.course_team = UserFactory()
factories.CourseUserRoleFactory(
course=self.course_run.course, role=PublisherUserRole.CourseTeam, user=self.course_team
)
UserAttributeFactory(user=self.user, enable_email_notification=True) UserAttributeFactory(user=self.user, enable_email_notification=True)
toggle_switch('enable_publisher_email_notifications', True) toggle_switch('enable_publisher_email_notifications', True)
...@@ -172,22 +177,30 @@ class StudioInstanceCreatedEmailTests(TestCase): ...@@ -172,22 +177,30 @@ class StudioInstanceCreatedEmailTests(TestCase):
""" Verify that emails sent successfully for studio instance created.""" """ Verify that emails sent successfully for studio instance created."""
emails.send_email_for_studio_instance_created(self.course_run) emails.send_email_for_studio_instance_created(self.course_run)
# assert email sent # assert email sent
self.assert_email_sent( self.assert_email_sent(
reverse('publisher:publisher_course_run_detail', kwargs={'pk': self.course_run.id}), reverse('publisher:publisher_course_run_detail', kwargs={'pk': self.course_run.id}),
'Studio instance created', 'Studio instance created',
'Studio instance created for the following course run' 'EdX has created a Studio instance for'
) )
def assert_email_sent(self, object_path, subject, expected_body): def assert_email_sent(self, object_path, subject, expected_body):
""" DRY method to assert sent email data""" """ DRY method to assert sent email data"""
self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox), 1)
self.assertEqual([settings.PUBLISHER_FROM_EMAIL], mail.outbox[0].to) self.assertEqual([settings.PUBLISHER_FROM_EMAIL], mail.outbox[0].to)
self.assertEqual([self.user.email], mail.outbox[0].bcc) self.assertEqual([self.user.email, self.course_team.email], mail.outbox[0].bcc)
self.assertEqual(str(mail.outbox[0].subject), subject) self.assertEqual(str(mail.outbox[0].subject), subject)
body = mail.outbox[0].body.strip() body = mail.outbox[0].body.strip()
self.assertIn(expected_body, body) self.assertIn(expected_body, body)
page_url = 'https://{host}{path}'.format(host=Site.objects.get_current().domain.strip('/'), path=object_path) page_url = 'https://{host}{path}'.format(host=Site.objects.get_current().domain.strip('/'), path=object_path)
self.assertIn(page_url, body) self.assertIn(page_url, body)
self.assertIn('You can now edit this course in Studio.', body)
self.assertIn('Thanks', body)
self.assertIn('This email address is unable to receive replies. For questions or comments', body)
self.assertIn(self.course_team.full_name, body)
self.assertIn(self.user.full_name, body)
self.assertIn('Note: This email address is unable to receive replies.', body)
self.assertIn(
'For questions or comments, contact {}.'.format(self.user.email), body
)
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-09 18:20+0500\n" "POT-Creation-Date: 2017-01-10 13:00+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -1853,8 +1853,6 @@ msgstr "" ...@@ -1853,8 +1853,6 @@ msgstr ""
#: templates/publisher/email/change_state.txt #: templates/publisher/email/change_state.txt
#: templates/publisher/email/comment.html #: templates/publisher/email/comment.html
#: templates/publisher/email/comment.txt #: templates/publisher/email/comment.txt
#: templates/publisher/email/studio_instance_created.html
#: templates/publisher/email/studio_instance_created.txt
msgid "The edX team" msgid "The edX team"
msgstr "" msgstr ""
...@@ -1879,33 +1877,55 @@ msgid "View comment: " ...@@ -1879,33 +1877,55 @@ msgid "View comment: "
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_created.html #: templates/publisher/email/studio_instance_created.html
#: templates/publisher/email/studio_instance_created.txt
#, python-format #, python-format
msgid "" msgid "Dear %(course_team_name)s,"
"Studio instance created for the following course run: "
"%(link_start)s%(course_run_page_url)s%(link_middle)scourse run "
"link%(link_end)s."
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_created.txt #: templates/publisher/email/studio_instance_created.html
#, python-format #, python-format
msgid "" msgid ""
"Studio instance created for the following course run: " "EdX has created a Studio instance for "
"%(course_run_page_url)s" "%(link_start)s%(course_run_page_url)s%(link_middle)s %(course_name)s "
"%(link_end)s. You can now edit this course in Studio."
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_created.html
#: templates/publisher/email/studio_instance_created.txt
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt #: templates/publisher/email/studio_instance_needed.txt
msgid "Dear" msgid "Thanks,"
msgstr ""
#: templates/publisher/email/studio_instance_created.html
#, python-format
msgid ""
"<p>Note: This email address is unable to receive replies. For questions or "
"comments, contact %(contact_us_email)s.</p>"
msgstr ""
#: templates/publisher/email/studio_instance_created.txt
#, python-format
msgid ""
"EdX has created a Studio instance for %(course_name)s: "
"%(course_run_page_url)s. You can now edit this course in Studio."
msgstr ""
#: templates/publisher/email/studio_instance_created.txt
#, python-format
msgid ""
"Note: This email address is unable to receive replies. For questions or "
"comments, contact %(contact_us_email)s."
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt #: templates/publisher/email/studio_instance_needed.txt
msgid "Please create a Studio instance for the following course." msgid "Dear"
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt #: templates/publisher/email/studio_instance_needed.txt
msgid "Thanks," msgid "Please create a Studio instance for the following course."
msgstr "" msgstr ""
#: templates/publisher/seat_form.html #: templates/publisher/seat_form.html
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-09 18:20+0500\n" "POT-Creation-Date: 2017-01-10 13:00+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-09 18:20+0500\n" "POT-Creation-Date: 2017-01-10 13:00+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -2162,8 +2162,6 @@ msgstr "Vïéw Çöürsé Ⱡ'σяєм ιρѕυм ∂σłσя #" ...@@ -2162,8 +2162,6 @@ msgstr "Vïéw Çöürsé Ⱡ'σяєм ιρѕυм ∂σłσя #"
#: templates/publisher/email/change_state.txt #: templates/publisher/email/change_state.txt
#: templates/publisher/email/comment.html #: templates/publisher/email/comment.html
#: templates/publisher/email/comment.txt #: templates/publisher/email/comment.txt
#: templates/publisher/email/studio_instance_created.html
#: templates/publisher/email/studio_instance_created.txt
msgid "The edX team" msgid "The edX team"
msgstr "Thé édX téäm Ⱡ'σяєм ιρѕυм ∂σłσя ѕ#" msgstr "Thé édX téäm Ⱡ'σяєм ιρѕυм ∂σłσя ѕ#"
...@@ -2190,24 +2188,57 @@ msgid "View comment: " ...@@ -2190,24 +2188,57 @@ msgid "View comment: "
msgstr "Vïéw çömmént: Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт#" msgstr "Vïéw çömmént: Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт#"
#: templates/publisher/email/studio_instance_created.html #: templates/publisher/email/studio_instance_created.html
#: templates/publisher/email/studio_instance_created.txt
#, python-format
msgid "Dear %(course_team_name)s,"
msgstr "Déär %(course_team_name)s, Ⱡ'σяєм ιρѕυм ∂σł#"
#: templates/publisher/email/studio_instance_created.html
#, python-format
msgid ""
"EdX has created a Studio instance for "
"%(link_start)s%(course_run_page_url)s%(link_middle)s %(course_name)s "
"%(link_end)s. You can now edit this course in Studio."
msgstr ""
"ÉdX häs çréätéd ä Stüdïö ïnstänçé för "
"%(link_start)s%(course_run_page_url)s%(link_middle)s %(course_name)s "
"%(link_end)s. Ýöü çän nöw édït thïs çöürsé ïn Stüdïö. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт"
" αмєт, #"
#: templates/publisher/email/studio_instance_created.html
#: templates/publisher/email/studio_instance_created.txt
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Thanks,"
msgstr "Thänks, Ⱡ'σяєм ιρѕυм #"
#: templates/publisher/email/studio_instance_created.html
#, python-format
msgid ""
"<p>Note: This email address is unable to receive replies. For questions or "
"comments, contact %(contact_us_email)s.</p>"
msgstr ""
"<p>Nöté: Thïs émäïl äddréss ïs ünäßlé tö réçéïvé réplïés. För qüéstïöns ör "
"çömménts, çöntäçt %(contact_us_email)s.</p> Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт#"
#: templates/publisher/email/studio_instance_created.txt
#, python-format #, python-format
msgid "" msgid ""
"Studio instance created for the following course run: " "EdX has created a Studio instance for %(course_name)s: "
"%(link_start)s%(course_run_page_url)s%(link_middle)scourse run " "%(course_run_page_url)s. You can now edit this course in Studio."
"link%(link_end)s."
msgstr "" msgstr ""
"Stüdïö ïnstänçé çréätéd för thé föllöwïng çöürsé rün: " "ÉdX häs çréätéd ä Stüdïö ïnstänçé för %(course_name)s: "
"%(link_start)s%(course_run_page_url)s%(link_middle)sçöürsé rün " "%(course_run_page_url)s. Ýöü çän nöw édït thïs çöürsé ïn Stüdïö. Ⱡ'σяєм "
"lïnk%(link_end)s. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тє#" "ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє#"
#: templates/publisher/email/studio_instance_created.txt #: templates/publisher/email/studio_instance_created.txt
#, python-format #, python-format
msgid "" msgid ""
"Studio instance created for the following course run: " "Note: This email address is unable to receive replies. For questions or "
"%(course_run_page_url)s" "comments, contact %(contact_us_email)s."
msgstr "" msgstr ""
"Stüdïö ïnstänçé çréätéd för thé föllöwïng çöürsé rün: " "Nöté: Thïs émäïl äddréss ïs ünäßlé tö réçéïvé réplïés. För qüéstïöns ör "
"%(course_run_page_url)s Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#" "çömménts, çöntäçt %(contact_us_email)s. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢#"
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt #: templates/publisher/email/studio_instance_needed.txt
...@@ -2221,11 +2252,6 @@ msgstr "" ...@@ -2221,11 +2252,6 @@ msgstr ""
"Pléäsé çréäté ä Stüdïö ïnstänçé för thé föllöwïng çöürsé. Ⱡ'σяєм ιρѕυм ∂σłσя" "Pléäsé çréäté ä Stüdïö ïnstänçé för thé föllöwïng çöürsé. Ⱡ'σяєм ιρѕυм ∂σłσя"
" ѕιт αмєт, ¢σηѕє¢тєтυя α#" " ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Thanks,"
msgstr "Thänks, Ⱡ'σяєм ιρѕυм #"
#: templates/publisher/seat_form.html #: templates/publisher/seat_form.html
msgid "Seat Form" msgid "Seat Form"
msgstr "Séät Förm Ⱡ'σяєм ιρѕυм ∂σł#" msgstr "Séät Förm Ⱡ'σяєм ιρѕυм ∂σł#"
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-09 18:20+0500\n" "POT-Creation-Date: 2017-01-10 13:00+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
......
...@@ -3,10 +3,25 @@ ...@@ -3,10 +3,25 @@
{% block body %} {% block body %}
<!-- Message Body --> <!-- Message Body -->
<p> <p>
<!--Translators: course_team_name is course team member name. .-->
{% blocktrans trimmed %}
Dear {{ course_team_name }},
{% endblocktrans %}
<p>
{% blocktrans with link_start='<a href="' link_middle='">' link_end='</a>' trimmed %} {% blocktrans with link_start='<a href="' link_middle='">' link_end='</a>' trimmed %}
Studio instance created for the following course run: {{ link_start }}{{ course_run_page_url }}{{ link_middle }}course run link{{ link_end }}. EdX has created a Studio instance for {{ link_start }}{{ course_run_page_url }}{{ link_middle }} {{ course_name }} {{ link_end }}.
You can now edit this course in Studio.
{% endblocktrans %} {% endblocktrans %}
</p> </p>
<p>{% trans "The edX team" %}</p>
<!--Translators: It's closing of mail.-->
<p>{% trans "Thanks," %}</p>
<p>{{ partner_coordinator_name }}</p>
{% blocktrans trimmed %}
<p>Note: This email address is unable to receive replies. For questions or comments, contact {{ contact_us_email }}.</p>
{% endblocktrans %}
<!-- End Message Body --> <!-- End Message Body -->
{% endblock body %} {% endblock body %}
{% load i18n %} {% load i18n %}
{% blocktrans trimmed %} {% blocktrans trimmed %}
Studio instance created for the following course run: {{ course_run_page_url }} Dear {{ course_team_name }},
{% endblocktrans %} {% endblocktrans %}
{% blocktrans trimmed %}
EdX has created a Studio instance for {{ course_name }}: {{ course_run_page_url }}.
You can now edit this course in Studio.
{% endblocktrans %}
{% trans "Thanks," %}
{{ partner_coordinator_name }}
{% trans "The edX team" %} {% blocktrans trimmed %}
Note: This email address is unable to receive replies. For questions or comments, contact {{ contact_us_email }}.
{% endblocktrans %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment