Give all XModuleDescriptors a module_class, and make it inheritance of js_module_names work
This commit is contained in:
@@ -194,11 +194,7 @@ except OSError as exc:
|
||||
fragments = set()
|
||||
for descriptor in XModuleDescriptor.load_classes() + [RawDescriptor]:
|
||||
descriptor_js = descriptor.get_javascript()
|
||||
module = getattr(descriptor, 'module_class', None)
|
||||
if module is not None:
|
||||
module_js = module.get_javascript()
|
||||
else:
|
||||
module_js = {}
|
||||
module_js = descriptor.module_class.get_javascript()
|
||||
|
||||
for filetype in ('coffee', 'js'):
|
||||
for fragment in descriptor_js.get(filetype, []) + module_js.get(filetype, []):
|
||||
|
||||
@@ -72,6 +72,7 @@ class CapaModule(XModule):
|
||||
icon_class = 'problem'
|
||||
|
||||
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')]}
|
||||
js_module_name = "Problem"
|
||||
|
||||
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
|
||||
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
|
||||
|
||||
@@ -13,6 +13,7 @@ class RawDescriptor(MakoModuleDescriptor, XmlDescriptor):
|
||||
mako_template = "widgets/raw-edit.html"
|
||||
|
||||
js = {'coffee': [resource_string(__name__, 'js/src/raw/edit.coffee')]}
|
||||
js_module_name = "RawDescriptor"
|
||||
|
||||
def get_context(self):
|
||||
return {
|
||||
|
||||
@@ -21,6 +21,7 @@ class SequenceModule(XModule):
|
||||
''' Layout module which lays out content in a temporal sequence
|
||||
'''
|
||||
js = {'coffee': [resource_string(__name__, 'js/src/sequence/display.coffee')]}
|
||||
js_module_name = "Sequence"
|
||||
|
||||
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
|
||||
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
|
||||
|
||||
@@ -18,8 +18,9 @@ class VideoModule(XModule):
|
||||
[resource_string(__name__, 'js/src/video/display.coffee')] +
|
||||
[resource_string(__name__, 'js/src/video/display/' + filename)
|
||||
for filename
|
||||
in resource_listdir(__name__, 'js/src/video/display')
|
||||
in sorted(resource_listdir(__name__, 'js/src/video/display'))
|
||||
]}
|
||||
js_module_name = "Video"
|
||||
|
||||
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
|
||||
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
|
||||
|
||||
@@ -78,6 +78,7 @@ class XModule(object):
|
||||
icon_class = 'other'
|
||||
|
||||
js = {}
|
||||
js_module_name = None
|
||||
|
||||
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
|
||||
'''
|
||||
@@ -197,10 +198,6 @@ class XModule(object):
|
||||
|
||||
# ================================== HTML INTERFACE DEFINITIONS ======================
|
||||
|
||||
@property
|
||||
def js_module_name(self):
|
||||
return self.__class__.__name__
|
||||
|
||||
@classmethod
|
||||
def get_javascript(cls):
|
||||
"""
|
||||
@@ -232,6 +229,8 @@ class XModuleDescriptor(Plugin):
|
||||
"""
|
||||
entry_point = "xmodule.v1"
|
||||
js = {}
|
||||
js_module_name = None
|
||||
module_class = XModule
|
||||
|
||||
# A list of metadata that this module can inherit from its parent module
|
||||
inheritable_metadata = (
|
||||
@@ -406,10 +405,6 @@ class XModuleDescriptor(Plugin):
|
||||
raise NotImplementedError('Modules must implement export_to_xml to enable xml export')
|
||||
|
||||
# ================================== HTML INTERFACE DEFINITIONS ======================
|
||||
@property
|
||||
def js_module_name(self):
|
||||
return self.__class__.__name__
|
||||
|
||||
@classmethod
|
||||
def get_javascript(cls):
|
||||
"""
|
||||
|
||||
@@ -344,11 +344,7 @@ except OSError as exc:
|
||||
|
||||
fragments = set()
|
||||
for descriptor in XModuleDescriptor.load_classes() + [HiddenDescriptor]:
|
||||
module = getattr(descriptor, 'module_class', None)
|
||||
if module is None:
|
||||
continue
|
||||
|
||||
js = module.get_javascript()
|
||||
module_js = descriptor.module_class.get_javascript()
|
||||
for filetype in ('coffee', 'js'):
|
||||
for fragment in js.get(filetype, []):
|
||||
fragments.add((filetype, fragment))
|
||||
|
||||
Reference in New Issue
Block a user