utils.py 639 Bytes
Newer Older
1
"""
cewing committed
2
CCX Enrollment operations for use by Coach APIs.
3 4 5

Does not include any access control, be sure to check access before calling.
"""
cewing committed
6
import logging
7

8
from .models import CustomCourseForEdX
cewing committed
9 10 11


log = logging.getLogger("edx.ccx")
12

cewing committed
13

14 15 16 17 18 19 20 21 22 23
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
24
        )
25 26
        return None
    return ccx[0]