From 287a00ee77cf1785bdd75652d18752d5e44df900 Mon Sep 17 00:00:00 2001 From: Harry Rein Date: Thu, 11 Jan 2018 12:34:46 -0500 Subject: [PATCH] Sort available sessions by start date. LEARNER-3734 --- openedx/core/djangoapps/catalog/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/catalog/utils.py b/openedx/core/djangoapps/catalog/utils.py index a407e5baf1..b1990c1277 100644 --- a/openedx/core/djangoapps/catalog/utils.py +++ b/openedx/core/djangoapps/catalog/utils.py @@ -270,7 +270,7 @@ def get_visible_sessions_for_entitlement(entitlement): def get_fulfillable_course_runs_for_entitlement(entitlement, course_runs): """ - Takes a list of course runs and returns only the course runs that: + Takes a list of course runs and returns only the course runs, sorted by start date, that: 1) Are currently running or in the future 2) A user can enroll in @@ -311,6 +311,7 @@ def get_fulfillable_course_runs_for_entitlement(entitlement, course_runs): if is_running and can_upgrade and can_enroll and is_published: enrollable_sessions.append(course_run) + enrollable_sessions.sort(key=lambda session: session.get('start')) return enrollable_sessions