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}