'Returns a list of course descriptors. This accepts an optional parameter of \'org\' which
will apply an efficient filter to only get courses with the specified ORG'

@autoretry_read()
def get_courses(self, **kwargs):

    course_org_filter = kwargs.get('org')
    if course_org_filter:
        course_records = self.collection.find({'_id.category': 'course', '_id.org': course_org_filter})
    else:
        course_records = self.collection.find({'_id.category': 'course'})
    base_list = sum([self._load_items(SlashSeparatedCourseKey(course['_id']['org'], course['_id']['course'], course['_id']['name']), [course]) for course in course_records if (not ((course['_id']['org'] == 'edx') and (course['_id']['course'] == 'templates')))], [])
    return [course for course in base_list if (not isinstance(course, ErrorDescriptor))]
