'Validate the course id'

def clean_course_id(self):

    cleaned_id = self.cleaned_data['course_id']
    try:
        course_key = CourseLocator.from_string(cleaned_id)
    except InvalidKeyError:
        msg = u'Course    id    invalid.    Entered    course    id    was:    "{course_id}."'.format(course_id=cleaned_id)
        raise forms.ValidationError(msg)
    if (not modulestore().has_course(course_key)):
        msg = u'Course    not    found.    Entered    course    id    was:    "{course_key}".    '.format(course_key=unicode(course_key))
        raise forms.ValidationError(msg)
    return course_key
