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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user