fix: Fix KeyError in vertical_block

This now mimics the way this is (safely) done in the sequence module [1].

References:
- [1] 5f94a082ce/common/lib/xmodule/xmodule/seq_module.py (L657-L658)
This commit is contained in:
stvn
2021-01-27 11:24:12 -08:00
parent 70cc6d8608
commit e09a5c9d94

View File

@@ -66,7 +66,9 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
usage_key=self.location), # pylint: disable=no-member
if 'username' not in child_context:
user_service = self.runtime.service(self, 'user')
child_context['username'] = user_service.get_current_user().opt_attrs['edx-platform.username']
child_context['username'] = user_service.get_current_user().opt_attrs.get(
'edx-platform.username'
)
child_blocks = self.get_display_items()