Skip to content
Snippets Groups Projects
Unverified Commit aab971ed authored by Matt Tuchfarber's avatar Matt Tuchfarber Committed by GitHub
Browse files

Merge pull request #18419 from edx/tuchfarber/fix_program_course_order

Change program's course runs to be oldest with open enrollment
parents a439d516 1eb4d213
Branches
Tags release-2020-10-02-11.03
No related merge requests found
......@@ -295,8 +295,11 @@ endorser_org = endorser_position.get('organization_name') or corporate_endorseme
</div>
% for course in courses:
<%
## Sort course runs by start date, reverse so newest is first, then take newest run
course_run = sorted(course['course_runs'], key=lambda run: run['start'], reverse=True)[0]
## The goal here is to get the `oldest course run that still has open enrollment`.
## We fall back on the newest course if none are available for enrollment.
sorted_course_runs = sorted(course['course_runs'], key=lambda run: run['start'])
open_course_runs = [run for run in sorted_course_runs if run['is_enrollment_open']]
course_run = open_course_runs[0] if open_course_runs else sorted_course_runs[-1]
course_img = course_run.get('image')
course_about_url = reverse('about_course', args=[course_run['key']])
course_purchase_url = course_run['upgrade_url'] if course_run['upgrade_url'] else course_about_url
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment