don't error out to user programs with really old course runs not in lms

This commit is contained in:
Emma Green
2018-10-17 15:42:01 -04:00
parent e39e6e9f87
commit ce7b094cfb

View File

@@ -494,10 +494,19 @@ class ProgramDataExtender(object):
for course_run in course['course_runs']:
# State to be shared across handlers.
self.course_run_key = CourseKey.from_string(course_run['key'])
self.course_overview = CourseOverview.get_from_id(self.course_run_key)
self.enrollment_start = self.course_overview.enrollment_start or DEFAULT_ENROLLMENT_START_DATE
self._execute('_attach_course_run', course_run)
# Some (old) course runs may exist for a program which do not exist in LMS. In that case,
# continue without the course run.
try:
self.course_overview = CourseOverview.get_from_id(self.course_run_key)
except CourseOverview.DoesNotExist:
log.warning('Failed to get course overview for course run key: %s',
self.course_run.get('key'),
exec_info=True)
else:
self.enrollment_start = self.course_overview.enrollment_start or DEFAULT_ENROLLMENT_START_DATE
self._execute('_attach_course_run', course_run)
def _attach_course_run_certificate_url(self, run_mode):
certificate_data = certificate_api.certificate_downloadable_status(self.user, self.course_run_key)