From 1ded8b546c18a899e9a7ca4002c74e0d648e6948 Mon Sep 17 00:00:00 2001 From: Tasawer Date: Wed, 15 Jul 2015 15:17:58 +0500 Subject: [PATCH] Update code of get_eligibility api. ECOM-1858 --- common/djangoapps/student/views.py | 3 ++- lms/envs/devstack.py | 7 +++++++ openedx/core/djangoapps/credit/api/eligibility.py | 8 +++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 73ea0c7311..03dd7ef302 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -63,6 +63,7 @@ from certificates.api import ( # pylint: disable=import-error from xmodule.modulestore.django import modulestore from opaque_keys import InvalidKeyError +from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator from xmodule.modulestore import ModuleStoreEnum @@ -867,7 +868,7 @@ def _credit_statuses(user, course_enrollments): statuses = {} for eligibility in credit_api.get_eligibilities_for_user(user.username): - course_key = eligibility["course_key"] + course_key = CourseKey.from_string(unicode(eligibility["course_key"])) status = { "course_key": unicode(course_key), "eligible": True, diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 39dfc584a2..d097e5a74a 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -184,6 +184,13 @@ if FEATURES.get('ENABLE_THIRD_PARTY_AUTH') and 'third_party_auth.dummy.DummyBack ############## ECOMMERCE API CONFIGURATION SETTINGS ############### ECOMMERCE_PUBLIC_URL_ROOT = "http://localhost:8002" +###################### Cross-domain requests ###################### +FEATURES['ENABLE_CORS_HEADERS'] = True +CORS_ALLOW_CREDENTIALS = True +CORS_ORIGIN_WHITELIST = () +CORS_ORIGIN_ALLOW_ALL = True + + ##################################################################### # See if the developer has any local overrides. try: diff --git a/openedx/core/djangoapps/credit/api/eligibility.py b/openedx/core/djangoapps/credit/api/eligibility.py index 349941b179..4b0d884179 100644 --- a/openedx/core/djangoapps/credit/api/eligibility.py +++ b/openedx/core/djangoapps/credit/api/eligibility.py @@ -13,6 +13,8 @@ from openedx.core.djangoapps.credit.models import ( CreditEligibility, ) +from opaque_keys.edx.keys import CourseKey + log = logging.getLogger(__name__) @@ -182,13 +184,13 @@ def get_eligibilities_for_user(username, course_key=None): """ eligibilities = CreditEligibility.get_user_eligibilities(username) - if course_key: - eligibilities = eligibilities.filter(course_key=course_key) + course_key = CourseKey.from_string(unicode(course_key)) + eligibilities = eligibilities.filter(course__course_key=course_key) return [ { - "course_key": eligibility.course.course_key, + "course_key": unicode(eligibility.course.course_key), "deadline": eligibility.deadline, } for eligibility in eligibilities