From 39563c327ccbfcd79ecec431c3345ab4bba4cfd3 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 14 Feb 2014 06:33:53 -0500 Subject: [PATCH] Make staff view work w/ pure xblocks (that only have a descriptor system) --- common/djangoapps/xmodule_modifiers.py | 4 ++-- common/lib/xmodule/xmodule/x_module.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/xmodule_modifiers.py b/common/djangoapps/xmodule_modifiers.py index fc95891063..21fb55c460 100644 --- a/common/djangoapps/xmodule_modifiers.py +++ b/common/djangoapps/xmodule_modifiers.py @@ -173,9 +173,9 @@ def add_staff_debug_info(user, block, view, frag, context): # pylint: disable=u histogram = None render_histogram = False - if settings.FEATURES.get('ENABLE_LMS_MIGRATION'): + if settings.FEATURES.get('ENABLE_LMS_MIGRATION') and hasattr(block.runtime, 'filestore'): [filepath, filename] = getattr(block, 'xml_attributes', {}).get('filename', ['', None]) - osfs = block.system.filestore + osfs = block.runtime.filestore if filename is not None and osfs.exists(filename): # if original, unmangled filename exists then use it (github # doesn't like symlinks) diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index a136edcdaf..e452536fae 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -141,6 +141,10 @@ class XModuleMixin(XBlockMixin): default=None ) + @property + def system(self): + return self.runtime + @property def course_id(self): return self.runtime.course_id @@ -400,7 +404,6 @@ class XModule(XModuleMixin, HTMLSnippet, XBlock): # pylint: disable=abstract-me self.descriptor = descriptor super(XModule, self).__init__(*args, **kwargs) self._loaded_children = None - self.system = self.runtime self.runtime.xmodule_instance = self def __unicode__(self): @@ -634,7 +637,6 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock): XModuleDescriptor.__init__ takes the same arguments as xblock.core:XBlock.__init__ """ super(XModuleDescriptor, self).__init__(*args, **kwargs) - self.system = self.runtime # update_version is the version which last updated this xblock v prev being the penultimate updater # leaving off original_version since it complicates creation w/o any obv value yet and is computable # by following previous until None