'Retrieve course modes for a list of courses.
To reduce the number of database queries, this function
loads *all* course modes, then creates a second list
of unexpired course modes.
Arguments:
course_id_list (list of `CourseKey`): List of courses for which
to retrieve course modes.
Returns:
Tuple of `(all_course_modes, unexpired_course_modes)`, where
the first is a list of *all* `Mode`s (including expired ones),
and the second is a list of only unexpired `Mode`s.'

@classmethod
def all_and_unexpired_modes_for_courses(cls, course_id_list):

    now = datetime.now(pytz.UTC)
    all_modes = cls.all_modes_for_courses(course_id_list)
    unexpired_modes = {course_id: [mode for mode in modes if ((mode.expiration_datetime is None) or (mode.expiration_datetime >= now))] for (course_id, modes) in all_modes.iteritems()}
    return (all_modes, unexpired_modes)
