Commit 1ded8b54 by Tasawer Committed by zubair-arbi

Update code of get_eligibility api.

ECOM-1858
parent ae0e21b3
...@@ -63,6 +63,7 @@ from certificates.api import ( # pylint: disable=import-error ...@@ -63,6 +63,7 @@ from certificates.api import ( # pylint: disable=import-error
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
...@@ -867,7 +868,7 @@ def _credit_statuses(user, course_enrollments): ...@@ -867,7 +868,7 @@ def _credit_statuses(user, course_enrollments):
statuses = {} statuses = {}
for eligibility in credit_api.get_eligibilities_for_user(user.username): 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 = { status = {
"course_key": unicode(course_key), "course_key": unicode(course_key),
"eligible": True, "eligible": True,
......
...@@ -184,6 +184,13 @@ if FEATURES.get('ENABLE_THIRD_PARTY_AUTH') and 'third_party_auth.dummy.DummyBack ...@@ -184,6 +184,13 @@ if FEATURES.get('ENABLE_THIRD_PARTY_AUTH') and 'third_party_auth.dummy.DummyBack
############## ECOMMERCE API CONFIGURATION SETTINGS ############### ############## ECOMMERCE API CONFIGURATION SETTINGS ###############
ECOMMERCE_PUBLIC_URL_ROOT = "http://localhost:8002" 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. # See if the developer has any local overrides.
try: try:
......
...@@ -13,6 +13,8 @@ from openedx.core.djangoapps.credit.models import ( ...@@ -13,6 +13,8 @@ from openedx.core.djangoapps.credit.models import (
CreditEligibility, CreditEligibility,
) )
from opaque_keys.edx.keys import CourseKey
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -182,13 +184,13 @@ def get_eligibilities_for_user(username, course_key=None): ...@@ -182,13 +184,13 @@ def get_eligibilities_for_user(username, course_key=None):
""" """
eligibilities = CreditEligibility.get_user_eligibilities(username) eligibilities = CreditEligibility.get_user_eligibilities(username)
if course_key: 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 [ return [
{ {
"course_key": eligibility.course.course_key, "course_key": unicode(eligibility.course.course_key),
"deadline": eligibility.deadline, "deadline": eligibility.deadline,
} }
for eligibility in eligibilities for eligibility in eligibilities
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment