Files
edx-platform/lms/djangoapps/ccx/utils.py
Usman Khalid 6cb62f2697 Rebase upgrade Django to v1.8.5
Please note that this is a squshed commit and the work of:
Symbolist, macdiesel, nedbat, doctoryes, muzaffaryousaf and muhammad-ammar
2015-11-10 15:00:19 -05:00

27 lines
657 B
Python

"""
CCX Enrollment operations for use by Coach APIs.
Does not include any access control, be sure to check access before calling.
"""
import logging
from lms.djangoapps.ccx.models import CustomCourseForEdX
log = logging.getLogger("edx.ccx")
def get_ccx_from_ccx_locator(course_id):
""" helper function to allow querying ccx fields from templates """
ccx_id = getattr(course_id, 'ccx', None)
ccx = None
if ccx_id:
ccx = CustomCourseForEdX.objects.filter(id=ccx_id)
if not ccx:
log.warning(
"CCX does not exist for course with id %s",
course_id
)
return None
return ccx[0]