'Returns a list of `CourseSummary`. 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_course_summaries(self, **kwargs):

    def extract_course_summary(course):
        '\n                                                Extract    course    information    from    the    course    block    for    mongo.\n                                                '
        return {field: course['metadata'][field] for field in CourseSummary.course_info_fields if (field in course['metadata'])}
    course_org_filter = kwargs.get('org')
    query = {'_id.category': 'course'}
    if course_org_filter:
        query['_id.org'] = course_org_filter
    course_records = self.collection.find(query, {'metadata': True})
    courses_summaries = []
    for course in course_records:
        if (not ((course['_id']['org'] == 'edx') and (course['_id']['course'] == 'templates'))):
            locator = SlashSeparatedCourseKey(course['_id']['org'], course['_id']['course'], course['_id']['name'])
            course_summary = extract_course_summary(course)
            courses_summaries.append(CourseSummary(locator, **course_summary))
    return courses_summaries
