'Returns the course_id of the course if it was found, else None
Note: we return the course_id instead of a boolean here since the found course may have
a different id than the given course_id when ignore_case is True.
If ignore_case is True, do a case insensitive search,
otherwise, do a case sensitive search'

@autoretry_read()
def has_course(self, course_key, ignore_case=False, **kwargs):

    assert isinstance(course_key, CourseKey)
    if (not course_key.deprecated):
        return False
    if isinstance(course_key, LibraryLocator):
        return None
    course_key = self.fill_in_run(course_key)
    location = course_key.make_usage_key('course', course_key.run)
    if ignore_case:
        course_query = location.to_deprecated_son('_id.')
        for key in course_query.iterkeys():
            if isinstance(course_query[key], basestring):
                course_query[key] = re.compile('(?i)^{}$'.format(course_query[key]))
    else:
        course_query = {'_id': location.to_deprecated_son()}
    course = self.collection.find_one(course_query, projection={'_id': True})
    if course:
        return SlashSeparatedCourseKey(course['_id']['org'], course['_id']['course'], course['_id']['name'])
    else:
        return None
