From 12708a093d0a61e8f3593233076f04aeed6e3fbf Mon Sep 17 00:00:00 2001 From: adeelehsan Date: Fri, 20 Dec 2019 09:59:06 +0500 Subject: [PATCH] Unsubscribe link added in bulk emails --- lms/djangoapps/bulk_email/api.py | 18 ++++++ .../fixtures/course_email_template.json | 8 +-- .../plain-html-no-newlines-or-tabs.txt | 2 +- .../fixtures/plain-html-no-newlines.txt | 2 +- .../bulk_email/fixtures/plain-html.txt | 57 ++++++++++--------- lms/djangoapps/bulk_email/tasks.py | 6 +- .../bulk_email/tests/test_course_optout.py | 26 +++++++++ lms/djangoapps/bulk_email/tests/test_email.py | 23 ++++++++ .../bulk_email/tests/test_models.py | 1 + lms/djangoapps/bulk_email/tests/test_views.py | 19 ++++--- lms/djangoapps/bulk_email/urls.py | 2 +- lms/djangoapps/bulk_email/views.py | 32 +++++------ lms/static/sass/shared/_unsubscribe.scss | 23 ++++++++ .../bulk_email/confirm_unsubscribe.html | 46 +++++++++++++++ lms/templates/bulk_email/unsubscribe.html | 48 ---------------- .../bulk_email/unsubscribe_success.html | 46 +++++++++++++++ 16 files changed, 250 insertions(+), 109 deletions(-) create mode 100644 lms/templates/bulk_email/confirm_unsubscribe.html delete mode 100644 lms/templates/bulk_email/unsubscribe.html create mode 100644 lms/templates/bulk_email/unsubscribe_success.html diff --git a/lms/djangoapps/bulk_email/api.py b/lms/djangoapps/bulk_email/api.py index f6b876b865..160d923bd5 100644 --- a/lms/djangoapps/bulk_email/api.py +++ b/lms/djangoapps/bulk_email/api.py @@ -12,6 +12,11 @@ from bulk_email.models_api import ( is_user_opted_out_for_course ) +from django.conf import settings +from django.urls import reverse + +from lms.djangoapps.discussion.notification_prefs.views import UsernameCipher + def get_emails_enabled(user, course_id): """ @@ -28,3 +33,16 @@ def get_emails_enabled(user, course_id): if is_bulk_email_feature_enabled(course_id=course_id): return not is_user_opted_out_for_course(user=user, course_id=course_id) return None + + +def get_unsubscribed_link(username, course_id): + """ + + :param username: username + :param course_id: + :return: AES encrypted token based on the user email + """ + token = UsernameCipher.encrypt(username) + optout_url = reverse('bulk_email_opt_out', kwargs={'token': token, 'course_id': course_id}) + url = '{base_url}{optout_url}'.format(base_url=settings.LMS_ROOT_URL, optout_url=optout_url) + return url diff --git a/lms/djangoapps/bulk_email/fixtures/course_email_template.json b/lms/djangoapps/bulk_email/fixtures/course_email_template.json index 93a08af4b4..d46857dd82 100644 --- a/lms/djangoapps/bulk_email/fixtures/course_email_template.json +++ b/lms/djangoapps/bulk_email/fixtures/course_email_template.json @@ -3,16 +3,16 @@ "pk": 1, "model": "bulk_email.courseemailtemplate", "fields": { - "plain_template": "{course_title}\n\n{{message_body}}\r\n----\r\nCopyright 2013 edX, All rights reserved.\r\n----\r\nConnect with edX:\r\nFacebook (http://facebook.com/edxonline)\r\nTwitter (http://twitter.com/edxonline)\r\nGoogle+ (https://plus.google.com/108235383044095082735)\r\nMeetup (http://www.meetup.com/edX-Communities/)\r\n----\r\nThis email was automatically sent from {platform_name}.\r\nYou are receiving this email at address {email} because you are enrolled in {course_title}\r\n(URL: {course_url} ).\r\nTo stop receiving email like this, update your course email settings at {email_settings_url}.\r\n", - "html_template": " Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.
" + "plain_template": "{course_title}\n\n{{message_body}}\r\n----\r\nCopyright 2013 edX, All rights reserved.\r\n----\r\nConnect with edX:\r\nFacebook (http://facebook.com/edxonline)\r\nTwitter (http://twitter.com/edxonline)\r\nGoogle+ (https://plus.google.com/108235383044095082735)\r\nMeetup (http://www.meetup.com/edX-Communities/)\r\n----\r\nThis email was automatically sent from {platform_name}.\r\nYou are receiving this email at address {email} because you are enrolled in {course_title}\r\n(URL: {course_url} ).\r\nTo stop receiving email like this, update your course email settings at {email_settings_url}.\r\n{unsubscribe_link}\r\n", + "html_template": " Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.

unsubscribe
" } }, { "pk": 2, "model": "bulk_email.courseemailtemplate", "fields": { - "plain_template": "THIS IS A BRANDED TEXT TEMPLATE. {course_title}\n\n{{message_body}}\r\n----\r\nCopyright 2013 edX, All rights reserved.\r\n----\r\nConnect with edX:\r\nFacebook (http://facebook.com/edxonline)\r\nTwitter (http://twitter.com/edxonline)\r\nGoogle+ (https://plus.google.com/108235383044095082735)\r\nMeetup (http://www.meetup.com/edX-Communities/)\r\n----\r\nThis email was automatically sent from {platform_name}.\r\nYou are receiving this email at address {email} because you are enrolled in {course_title}\r\n(URL: {course_url} ).\r\nTo stop receiving email like this, update your course email settings at {email_settings_url}.\r\n", - "html_template": " THIS IS A BRANDED HTML TEMPLATE Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.
", + "plain_template": "THIS IS A BRANDED TEXT TEMPLATE. {course_title}\n\n{{message_body}}\r\n----\r\nCopyright 2013 edX, All rights reserved.\r\n----\r\nConnect with edX:\r\nFacebook (http://facebook.com/edxonline)\r\nTwitter (http://twitter.com/edxonline)\r\nGoogle+ (https://plus.google.com/108235383044095082735)\r\nMeetup (http://www.meetup.com/edX-Communities/)\r\n----\r\nThis email was automatically sent from {platform_name}.\r\nYou are receiving this email at address {email} because you are enrolled in {course_title}\r\n(URL: {course_url} ).\r\nTo stop receiving email like this, update your course email settings at {email_settings_url}.\r\n{unsubscribe_link}\r\n", + "html_template": " THIS IS A BRANDED HTML TEMPLATE Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.

unsubscribe
", "name": "branded.template" } } diff --git a/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines-or-tabs.txt b/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines-or-tabs.txt index 34f5da6d18..ef98ab8310 100644 --- a/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines-or-tabs.txt +++ b/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines-or-tabs.txt @@ -1 +1 @@ - Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.
\ No newline at end of file + Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.

unsubscribe
diff --git a/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines.txt b/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines.txt index 4da5bd6553..6152fba7a4 100644 --- a/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines.txt +++ b/lms/djangoapps/bulk_email/fixtures/plain-html-no-newlines.txt @@ -1 +1 @@ - Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.
\ No newline at end of file + Update from {course_title}

edX
Connect with edX:        

{course_title}


{{message_body}}
       
Copyright © 2013 edX, All rights reserved.


Our mailing address is:
edX
11 Cambridge Center, Suite 101
Cambridge, MA, USA 02142


This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
To stop receiving email like this, update your course email settings here.

unsubscribe
diff --git a/lms/djangoapps/bulk_email/fixtures/plain-html.txt b/lms/djangoapps/bulk_email/fixtures/plain-html.txt index c9bc952ced..22db1250ca 100644 --- a/lms/djangoapps/bulk_email/fixtures/plain-html.txt +++ b/lms/djangoapps/bulk_email/fixtures/plain-html.txt @@ -24,25 +24,25 @@ - + - +
- +
- + - + @@ -63,11 +63,11 @@
- + edX - +
@@ -78,19 +78,19 @@ - + - +
- +
Connect with edX:        
- + @@ -115,7 +115,7 @@ - + @@ -123,11 +123,11 @@
- - + + - - + +
@@ -156,17 +156,17 @@ - + - +
{{message_body}}
- + @@ -188,19 +188,19 @@ - + - +
- +
       
- + @@ -225,12 +225,12 @@ - + - +
- + Copyright © 2013 edX, All rights reserved.


@@ -242,11 +242,12 @@
This email was automatically sent from {platform_name}.
You are receiving this email at address {email} because you are enrolled in {course_title}.
-To stop receiving email like this, update your course email settings here.
+To stop receiving email like this, update your course email settings here.

+unsubscribe
- + diff --git a/lms/djangoapps/bulk_email/tasks.py b/lms/djangoapps/bulk_email/tasks.py index e68b086d2f..4a4325fdad 100644 --- a/lms/djangoapps/bulk_email/tasks.py +++ b/lms/djangoapps/bulk_email/tasks.py @@ -41,6 +41,7 @@ from markupsafe import escape from six import text_type from bulk_email.models import CourseEmail, Optout +from bulk_email.api import get_unsubscribed_link from lms.djangoapps.courseware.courses import get_course from lms.djangoapps.instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.subtasks import ( @@ -187,7 +188,7 @@ def perform_delegate_email_batches(entry_id, course_id, task_input, action_name) # inefficient OUTER JOIN query that would read the whole user table. combined_set = recipient_qsets[0].union(*recipient_qsets[1:]) if len(recipient_qsets) > 1 \ else recipient_qsets[0] - recipient_fields = ['profile__name', 'email'] + recipient_fields = ['profile__name', 'email', 'username'] log.info(u"Task %s: Preparing to queue subtasks for sending emails for course %s, email %s", task_id, course_id, email_id) @@ -502,6 +503,7 @@ def _send_course_email(entry_id, email_id, to_list, global_email_context, subtas # use the CourseEmailTemplate that was associated with the CourseEmail course_email_template = course_email.get_template() + try: connection = get_connection() connection.open() @@ -537,6 +539,8 @@ def _send_course_email(entry_id, email_id, to_list, global_email_context, subtas email_context['name'] = current_recipient['profile__name'] email_context['user_id'] = current_recipient['pk'] email_context['course_id'] = course_email.course_id + email_context['unsubscribe_link'] = get_unsubscribed_link(current_recipient['username'], + text_type(course_email.course_id)) # Construct message content using templates and context: plaintext_msg = course_email_template.render_plaintext(course_email.text_message, email_context) diff --git a/lms/djangoapps/bulk_email/tests/test_course_optout.py b/lms/djangoapps/bulk_email/tests/test_course_optout.py index 3eebe0786c..fc03546ce8 100644 --- a/lms/djangoapps/bulk_email/tests/test_course_optout.py +++ b/lms/djangoapps/bulk_email/tests/test_course_optout.py @@ -23,6 +23,8 @@ from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserF from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory +from lms.djangoapps.bulk_email.api import get_unsubscribed_link + @patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) class TestOptoutCourseEmails(ModuleStoreTestCase): @@ -87,6 +89,30 @@ class TestOptoutCourseEmails(ModuleStoreTestCase): self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].to[0], self.instructor.email) + def test_optout_using_unsubscribe_link_in_email(self): + """ + Make sure email is't sent to learner after opt out. + """ + self.client.logout() + + self.client.login(username=self.instructor.username, password="test") + + unsubscribe_link = get_unsubscribed_link(self.student.username, text_type(self.course.id)) + response = self.client.post(unsubscribe_link, {'unsubscribe': True}) + + self.assertEqual(response.status_code, 200) + self.assertContains(response, 'You have successfully unsubscribed from') + + test_email = { + 'action': 'Send email', + 'send_to': '["myself", "learners"]', + 'subject': 'Checking unsubscribe link in email', + 'message': 'test message for all' + } + response = self.client.post(self.send_mail_url, test_email) + self.assertEqual(json.loads(response.content.decode('utf-8')), self.success_content) + self.assertEqual(len(mail.outbox), 1) + def test_optin_course(self): """ Make sure student receives course email after opting in. diff --git a/lms/djangoapps/bulk_email/tests/test_email.py b/lms/djangoapps/bulk_email/tests/test_email.py index a8d3f57467..7ec87ea5cb 100644 --- a/lms/djangoapps/bulk_email/tests/test_email.py +++ b/lms/djangoapps/bulk_email/tests/test_email.py @@ -24,6 +24,7 @@ from mock import Mock, patch from bulk_email.models import BulkEmailFlag, Optout from bulk_email.tasks import _get_course_email_context, _get_source_address from course_modes.models import CourseMode + from lms.djangoapps.courseware.tests.factories import InstructorFactory, StaffFactory from lms.djangoapps.instructor_task.subtasks import update_subtask_status from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort @@ -603,6 +604,28 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase) [s.email for s in added_users if s not in optouts]) six.assertCountEqual(self, outbox_contents, should_send_contents) + def test_unsubscribe_link_in_email(self): + """ + Make sure opt out link is present in email. + """ + + test_email = { + 'action': 'Send email', + 'send_to': '["learners"]', + 'subject': 'Checking unsubscribe link in email', + 'message': 'test message for all' + } + response = self.client.post(self.send_mail_url, test_email) + self.assertEqual(json.loads(response.content.decode('utf-8')), self.success_content) + + # check unsubscribe link in template + for m in mail.outbox: + plain_template = m.body + html_template = m.alternatives[0][0] + + assert u'bulk_email/email/optout/' in plain_template + assert u'bulk_email/email/optout/' in html_template + @skipIf(os.environ.get("TRAVIS") == 'true', "Skip this test in Travis CI.") class TestEmailSendFromDashboard(EmailSendFromDashboardTestCase): diff --git a/lms/djangoapps/bulk_email/tests/test_models.py b/lms/djangoapps/bulk_email/tests/test_models.py index 02589819e3..dad44c92cc 100644 --- a/lms/djangoapps/bulk_email/tests/test_models.py +++ b/lms/djangoapps/bulk_email/tests/test_models.py @@ -188,6 +188,7 @@ class CourseEmailTemplateTest(TestCase): 'email_settings_url': "/location/of/email/settings/url", 'platform_name': 'edX', 'email': 'your-email@test.com', + 'unsubscribe_link': '/bulk_email/email/optout/dummy' } return context diff --git a/lms/djangoapps/bulk_email/tests/test_views.py b/lms/djangoapps/bulk_email/tests/test_views.py index 54151b8b98..69e75f5c8e 100644 --- a/lms/djangoapps/bulk_email/tests/test_views.py +++ b/lms/djangoapps/bulk_email/tests/test_views.py @@ -2,7 +2,6 @@ """ Test the bulk email opt out view. """ -from six import text_type import ddt from django.http import Http404 @@ -12,6 +11,8 @@ from django.urls import reverse from bulk_email.models import Optout from bulk_email.views import opt_out_email_updates +from six import text_type + from lms.djangoapps.discussion.notification_prefs.views import UsernameCipher from openedx.core.lib.tests import attr from student.tests.factories import UserFactory @@ -28,10 +29,10 @@ class OptOutEmailUpdatesViewTest(ModuleStoreTestCase): """ def setUp(self): super(OptOutEmailUpdatesViewTest, self).setUp() - self.user = UserFactory.create(username="testuser1") + self.user = UserFactory.create(username="testuser1", email='test@example.com') + self.course = CourseFactory.create(run='testcourse1', display_name='Test Course Title') self.token = UsernameCipher.encrypt('testuser1') self.request_factory = RequestFactory() - self.course = CourseFactory.create(run='testcourse1', display_name='Test Course Title') self.url = reverse('bulk_email_opt_out', args=[self.token, text_type(self.course.id)]) # Ensure we start with no opt-out records @@ -42,28 +43,28 @@ class OptOutEmailUpdatesViewTest(ModuleStoreTestCase): Ensure that the default GET view asks for confirmation. """ response = self.client.get(self.url) - self.assertContains(response, "Do you want to unsubscribe from emails for Test Course Title?") + self.assertContains(response, "confirm unsubscribe from") self.assertEqual(Optout.objects.count(), 0) def test_opt_out_email_unsubscribe(self): """ Ensure that the POSTing "confirm" creates the opt-out record. """ - response = self.client.post(self.url, {'submit': 'confirm'}) - self.assertContains(response, "You have been unsubscribed from emails for Test Course Title.") + response = self.client.post(self.url, {'unsubscribe': True}) + self.assertContains(response, "You have successfully unsubscribed from") self.assertEqual(Optout.objects.count(), 1) def test_opt_out_email_cancel(self): """ Ensure that the POSTing "cancel" does not create the opt-out record """ - response = self.client.post(self.url, {'submit': 'cancel'}) - self.assertContains(response, "You have not been unsubscribed from emails for Test Course Title.") + response = self.client.post(self.url) + self.assertContains(response, "You have not been unsubscribed from") self.assertEqual(Optout.objects.count(), 0) @ddt.data( ("ZOMG INVALID BASE64 CHARS!!!", "base64url", False), - ("Non-ASCII\xff", "base64url", False), + ("Non-ASCII\xff".encode(), "base64url", False), ("D6L8Q01ztywqnr3coMOlq0C3DG05686lXX_1ArEd0ok", "base64url", False), ("AAAAAAAAAAA=", "initialization_vector", False), ("nMXVK7PdSlKPOovci-M7iqS09Ux8VoCNDJixLBmj", "aes", False), diff --git a/lms/djangoapps/bulk_email/urls.py b/lms/djangoapps/bulk_email/urls.py index 9beea793e1..6766c2050c 100644 --- a/lms/djangoapps/bulk_email/urls.py +++ b/lms/djangoapps/bulk_email/urls.py @@ -2,8 +2,8 @@ URLs for bulk_email app """ -from django.conf import settings from django.conf.urls import url +from django.conf import settings from bulk_email import views diff --git a/lms/djangoapps/bulk_email/views.py b/lms/djangoapps/bulk_email/views.py index 3b784fe9f9..9358703884 100644 --- a/lms/djangoapps/bulk_email/views.py +++ b/lms/djangoapps/bulk_email/views.py @@ -35,8 +35,9 @@ def opt_out_email_updates(request, token, course_id): Raises a 404 if there are any errors parsing the input. """ + try: - username = UsernameCipher().decrypt(token.encode()) + username = UsernameCipher().decrypt(token) user = User.objects.get(username=username) course_key = CourseKey.from_string(course_id) course = get_course_by_id(course_key, depth=0) @@ -49,23 +50,22 @@ def opt_out_email_updates(request, token, course_id): except InvalidKeyError: raise Http404("course") + unsub_check = request.POST.get('unsubscribe', False) context = { 'course': course, - 'cancelled': False, - 'confirmed': False, + 'unsubscribe': unsub_check } - if request.method == 'POST': - if request.POST.get('submit') == 'confirm': - Optout.objects.get_or_create(user=user, course_id=course.id) - log.info( - u"User %s (%s) opted out of receiving emails from course %s", - user.username, - user.email, - course_id, - ) - context['confirmed'] = True - else: - context['cancelled'] = True + if request.method == 'GET': + return render_to_response('bulk_email/confirm_unsubscribe.html', context) - return render_to_response('bulk_email/unsubscribe.html', context) + if request.method == 'POST' and unsub_check: + Optout.objects.get_or_create(user=user, course_id=course_key) + log.info( + u"User %s (%s) opted out of receiving emails from course %s", + user.username, + user.email, + course_id, + ) + + return render_to_response('bulk_email/unsubscribe_success.html', context) diff --git a/lms/static/sass/shared/_unsubscribe.scss b/lms/static/sass/shared/_unsubscribe.scss index 7bbf62e475..cc38e0beb2 100644 --- a/lms/static/sass/shared/_unsubscribe.scss +++ b/lms/static/sass/shared/_unsubscribe.scss @@ -22,3 +22,26 @@ width: flex-grid(6); } } + + +.container.unsubscribe-bulk-email { + max-width: 400px; + min-width: 320px; + margin: 0 auto; + padding: ($baseline*3) 15px ($baseline*6); + + h1 { + @include text-align(left); + + font-size: 30px; + } + + .button { + background-color: #23419f; + border-color: #23419f; + border: 2px solid; + border-radius: 25px; + text-align: center; + width: 100%; + } +} diff --git a/lms/templates/bulk_email/confirm_unsubscribe.html b/lms/templates/bulk_email/confirm_unsubscribe.html new file mode 100644 index 0000000000..2e50dd6444 --- /dev/null +++ b/lms/templates/bulk_email/confirm_unsubscribe.html @@ -0,0 +1,46 @@ +<%page expression_filter="h"/> +<%! +from openedx.core.djangolib.markup import Text, HTML +from django.utils.translation import ugettext as _ + +%> +<%inherit file="../main.html" /> + +<%namespace name='static' file='../static_content.html'/> + +<%block name="pagetitle">${Text(_("Unsubscribe"))} +
+ +
+

+ + <%block name="pageheader">${Text(_("Unsubscribe"))} + +

+ +
+ + <%block name="pagecontent"> + + + + ${Text(_("confirm unsubscribe from {org} {course} emails.")).format( + org=HTML("{}'s").format(course.display_org_with_default), + course=HTML("{}").format(course.display_name_with_default) + ) + } +

+

+ ${_("Note:")} + ${_("You will still receive course emails from other courses you are enrolled in.")} +

+

+ + + + +
+ + +
+
diff --git a/lms/templates/bulk_email/unsubscribe.html b/lms/templates/bulk_email/unsubscribe.html deleted file mode 100644 index 270f8dc604..0000000000 --- a/lms/templates/bulk_email/unsubscribe.html +++ /dev/null @@ -1,48 +0,0 @@ -<%page expression_filter="h" /> -<%inherit file="../main.html" /> -<%! - from openedx.core.djangolib.markup import Text - from django.utils.translation import ugettext as _ -%> -<%def name="header()"> -%if confirmed: - ${Text(_("Unsubscribe Successful"))} -%elif cancelled: - ${Text(_("Unsubscribe Cancelled"))} -%else: - ${Text(_("Confirm Unsubscribe"))} -%endif - - -<%block name="pagetitle">${header()} -
- -
-

- <%block name="pageheader">${header()} -

-

- <%block name="pagecontent"> - %if confirmed: - ${Text(_("You have been unsubscribed from emails for {course}.")).format( - course=course.display_name_with_default - )} - %elif cancelled: - ${Text(_("You have not been unsubscribed from emails for {course}.")).format( - course=course.display_name_with_default - )} - %else: - ${Text(_("Do you want to unsubscribe from emails for {course}?")).format( - course=course.display_name_with_default - )} -

-

- - - -
- %endif - -

-
-
diff --git a/lms/templates/bulk_email/unsubscribe_success.html b/lms/templates/bulk_email/unsubscribe_success.html new file mode 100644 index 0000000000..6c77df6236 --- /dev/null +++ b/lms/templates/bulk_email/unsubscribe_success.html @@ -0,0 +1,46 @@ +<%page expression_filter="h"/> +<%! +from openedx.core.djangolib.markup import HTML, Text +from django.utils.translation import ugettext as _ + +%> +<%inherit file="../main.html" /> + +<%namespace name='static' file='../static_content.html'/> + +<%block name="pagetitle">${Text(_("Unsubscribe"))} +
+ +
+

+ + <%block name="pageheader">${Text(_("Unsubscribe"))} + +

+ + <%block name="pagecontent"> + + %if unsubscribe: + ${Text(_("You have successfully unsubscribed from {org} {course} emails.")).format( + org=HTML("{}'s").format(course.display_org_with_default), + course=HTML("{}").format(course.display_name_with_default) + )} + + %else: + ${Text(_("You have not been unsubscribed from {org} {course} emails.")).format( + org=HTML("{}'s").format(course.display_org_with_default), + course=HTML("{}").format(course.display_name_with_default) + )} + + %endif +

+ ${Text(_("{link_start}Return to edX.org{link_end}")).format( + link_start=HTML(" "), + link_end=HTML(" "), + )} + + + +
+ +