'Generator that yields all courses.'

@classmethod
def iterator(cls):

    course_modes = CourseMode.objects.order_by('course_id')
    for (course_id, modes) in groupby(course_modes, (lambda o: o.course_id)):
        (yield cls(course_id, list(modes)))
