Files
edx-platform/lms/static/js/student_account/emailoptin.js
stephensanchez 32c9230cd1 Hooking the logistration page into the new HTTP endpoint for email opt in.
Update the PR based on Code Review comments, and additional tests.

Using underscore js
2014-12-01 17:25:57 +00:00

36 lines
1019 B
JavaScript

var edx = edx || {};
(function($) {
'use strict';
edx.student = edx.student || {};
edx.student.account = edx.student.account || {};
edx.student.account.EmailOptInInterface = {
urls: {
emailOptInUrl: '/user_api/v1/preferences/email_opt_in/'
},
headers: {
'X-CSRFToken': $.cookie('csrftoken')
},
/**
* Set the email opt in setting for the organization associated
* with this course.
* @param {string} courseKey Slash-separated course key.
* @param {string} emailOptIn The preference to opt in or out of organization emails.
*/
setPreference: function( courseKey, emailOptIn, context ) {
return $.ajax({
url: this.urls.emailOptInUrl,
type: 'POST',
data: {course_id: courseKey, email_opt_in: emailOptIn},
headers: this.headers,
context: context
});
}
};
})(jQuery);