Unverified Commit 1d8613f3 by Matt Tuchfarber Committed by GitHub

Merge pull request #16602 from edx/tuchfarber/fix_instructor_ordering

Fix instructors ordering on program marketing page
parents 4a938c14 2c67f964
......@@ -604,8 +604,8 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
def __init__(self, program_data, user):
super(ProgramMarketingDataExtender, self).__init__(program_data, user)
# Aggregate dict of instructors for the program keyed by name
self.instructors = {}
# Aggregate list of instructors for the program
self.instructors = []
# Values for programs' price calculation.
self.data['avg_price_per_course'] = 0.0
......@@ -627,7 +627,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
if not program_instructors:
# We cache the program instructors list to avoid repeated modulestore queries
program_instructors = self.instructors.values()
program_instructors = self.instructors
cache.set(cache_key, program_instructors, 3600)
self.data['instructors'] = program_instructors
......@@ -687,6 +687,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
course_instructors = getattr(course_descriptor, 'instructor_info', {})
# Deduplicate program instructors using instructor name
self.instructors.update(
{instructor.get('name', '').strip(): instructor for instructor in course_instructors.get('instructors', [])}
)
curr_instructors_names = [instructor.get('name', '').strip() for instructor in self.instructors]
for instructor in course_instructors.get('instructors', []):
if instructor.get('name', '').strip() not in curr_instructors_names:
self.instructors.append(instructor)
Markdown is supported
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