diff --git a/common/djangoapps/student/tests/test_credit.py b/common/djangoapps/student/tests/test_credit.py index f8acdfc946..054aafed25 100644 --- a/common/djangoapps/student/tests/test_credit.py +++ b/common/djangoapps/student/tests/test_credit.py @@ -86,7 +86,8 @@ class CreditCourseDashboardTest(ModuleStoreTestCase): def test_not_eligible_for_credit(self): # The user is not yet eligible for credit, so no additional information should be displayed on the dashboard. response = self._load_dashboard() - self.assertNotContains(response, "credit") + self.assertNotContains(response, "credit-eligibility-msg") + self.assertNotContains(response, "purchase-credit-btn") def test_eligible_for_credit(self): # Simulate that the user has completed the only requirement in the course diff --git a/lms/envs/common.py b/lms/envs/common.py index 151fea82a7..305b092032 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -413,7 +413,7 @@ FEATURES = { 'ENABLE_OPENBADGES': False, # Credit course API - 'ENABLE_CREDIT_API': False, + 'ENABLE_CREDIT_API': True, # The block types to disable need to be specified in "x block disable config" in django admin. 'ENABLE_DISABLING_XBLOCK_TYPES': True, @@ -2122,7 +2122,7 @@ if FEATURES.get('CLASS_DASHBOARD'): INSTALLED_APPS += ('class_dashboard',) ################ Enable credit eligibility feature #################### -ENABLE_CREDIT_ELIGIBILITY = False +ENABLE_CREDIT_ELIGIBILITY = True FEATURES['ENABLE_CREDIT_ELIGIBILITY'] = ENABLE_CREDIT_ELIGIBILITY ######################## CAS authentication ########################### diff --git a/lms/static/js/commerce/credit.js b/lms/static/js/commerce/credit.js new file mode 100644 index 0000000000..516127aa51 --- /dev/null +++ b/lms/static/js/commerce/credit.js @@ -0,0 +1,42 @@ +/** + * Credit-related utilities + */ +var edx = edx || {}; + +(function ($, _) { + 'use strict'; + + edx.commerce = edx.commerce || {}; + edx.commerce.credit = edx.commerce.credit || {}; + + edx.commerce.credit.createCreditRequest = function (providerId, courseKey, username) { + return $.ajax({ + url: '/api/credit/v1/providers/' + providerId + '/request/', + type: 'POST', + headers: { + 'X-CSRFToken': $.cookie('csrftoken') + }, + data: JSON.stringify({ + 'course_key': courseKey, + 'username': username + }), + context: this, + success: function (requestData) { + var $form = $('