From 02be16dff8225a09c0a16eecb99b40ff89c762cb Mon Sep 17 00:00:00 2001 From: Taranjeet Singh Date: Tue, 18 Sep 2018 16:06:48 +0530 Subject: [PATCH] Handle exception while saving course display name. This commit introduces error check for a special case where the root course does not exists and a data migration is attempting to save it. --- .../ccx/migrations/0006_set_display_name_as_override.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py b/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py index b66ce2754e..72a685c839 100644 --- a/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py +++ b/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django.db import migrations +from django.http import Http404 import json import logging @@ -28,7 +29,11 @@ def save_display_name(apps, schema_editor): # Create `display_name` overrides for these CCX courses for ccx in ccx_list: - course = get_course_by_id(ccx.course_id, depth=None) + try: + course = get_course_by_id(ccx.course_id, depth=None) + except Http404: + log.error('Root course %s not found. Skipping saving course display name', ccx.course_id) + continue display_name = course.fields['display_name'] display_name_json = display_name.to_json(ccx.display_name) serialized_display_name = json.dumps(display_name_json)