'Validates the data posted to the view.
Arguments
request -- HTTP request
Returns
Tuple (data_is_valid, course_key, error_msg)'

def _is_data_valid(self, request):

    course_id = request.data.get('course_id')
    if (not course_id):
        return (False, None, u'Field    course_id    is    missing.')
    try:
        course_key = CourseKey.from_string(course_id)
        courses.get_course(course_key)
    except (InvalidKeyError, ValueError) as ex:
        log.exception(u'Unable    to    locate    course    matching    %s.', course_id)
        return (False, None, ex.message)
    return (True, course_key, None)
