Commit 5026d6e9 by Calen Pennington

Give all XModuleDescriptors a module_class, and make it inheritance of js_module_names work

parent 3cdceab1
...@@ -194,11 +194,7 @@ except OSError as exc: ...@@ -194,11 +194,7 @@ except OSError as exc:
fragments = set() fragments = set()
for descriptor in XModuleDescriptor.load_classes() + [RawDescriptor]: for descriptor in XModuleDescriptor.load_classes() + [RawDescriptor]:
descriptor_js = descriptor.get_javascript() descriptor_js = descriptor.get_javascript()
module = getattr(descriptor, 'module_class', None) module_js = descriptor.module_class.get_javascript()
if module is not None:
module_js = module.get_javascript()
else:
module_js = {}
for filetype in ('coffee', 'js'): for filetype in ('coffee', 'js'):
for fragment in descriptor_js.get(filetype, []) + module_js.get(filetype, []): for fragment in descriptor_js.get(filetype, []) + module_js.get(filetype, []):
......
...@@ -72,6 +72,7 @@ class CapaModule(XModule): ...@@ -72,6 +72,7 @@ class CapaModule(XModule):
icon_class = 'problem' icon_class = 'problem'
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')]} 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): def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs) XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
......
...@@ -13,6 +13,7 @@ class RawDescriptor(MakoModuleDescriptor, XmlDescriptor): ...@@ -13,6 +13,7 @@ class RawDescriptor(MakoModuleDescriptor, XmlDescriptor):
mako_template = "widgets/raw-edit.html" mako_template = "widgets/raw-edit.html"
js = {'coffee': [resource_string(__name__, 'js/src/raw/edit.coffee')]} js = {'coffee': [resource_string(__name__, 'js/src/raw/edit.coffee')]}
js_module_name = "RawDescriptor"
def get_context(self): def get_context(self):
return { return {
......
...@@ -21,6 +21,7 @@ class SequenceModule(XModule): ...@@ -21,6 +21,7 @@ class SequenceModule(XModule):
''' Layout module which lays out content in a temporal sequence ''' Layout module which lays out content in a temporal sequence
''' '''
js = {'coffee': [resource_string(__name__, 'js/src/sequence/display.coffee')]} 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): def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs) XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
......
...@@ -18,8 +18,9 @@ class VideoModule(XModule): ...@@ -18,8 +18,9 @@ class VideoModule(XModule):
[resource_string(__name__, 'js/src/video/display.coffee')] + [resource_string(__name__, 'js/src/video/display.coffee')] +
[resource_string(__name__, 'js/src/video/display/' + filename) [resource_string(__name__, 'js/src/video/display/' + filename)
for 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): def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs) XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
......
...@@ -78,6 +78,7 @@ class XModule(object): ...@@ -78,6 +78,7 @@ class XModule(object):
icon_class = 'other' icon_class = 'other'
js = {} js = {}
js_module_name = None
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs): def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
''' '''
...@@ -197,10 +198,6 @@ class XModule(object): ...@@ -197,10 +198,6 @@ class XModule(object):
# ================================== HTML INTERFACE DEFINITIONS ====================== # ================================== HTML INTERFACE DEFINITIONS ======================
@property
def js_module_name(self):
return self.__class__.__name__
@classmethod @classmethod
def get_javascript(cls): def get_javascript(cls):
""" """
...@@ -232,6 +229,8 @@ class XModuleDescriptor(Plugin): ...@@ -232,6 +229,8 @@ class XModuleDescriptor(Plugin):
""" """
entry_point = "xmodule.v1" entry_point = "xmodule.v1"
js = {} js = {}
js_module_name = None
module_class = XModule
# A list of metadata that this module can inherit from its parent module # A list of metadata that this module can inherit from its parent module
inheritable_metadata = ( inheritable_metadata = (
...@@ -406,10 +405,6 @@ class XModuleDescriptor(Plugin): ...@@ -406,10 +405,6 @@ class XModuleDescriptor(Plugin):
raise NotImplementedError('Modules must implement export_to_xml to enable xml export') raise NotImplementedError('Modules must implement export_to_xml to enable xml export')
# ================================== HTML INTERFACE DEFINITIONS ====================== # ================================== HTML INTERFACE DEFINITIONS ======================
@property
def js_module_name(self):
return self.__class__.__name__
@classmethod @classmethod
def get_javascript(cls): def get_javascript(cls):
""" """
......
...@@ -344,11 +344,7 @@ except OSError as exc: ...@@ -344,11 +344,7 @@ except OSError as exc:
fragments = set() fragments = set()
for descriptor in XModuleDescriptor.load_classes() + [HiddenDescriptor]: for descriptor in XModuleDescriptor.load_classes() + [HiddenDescriptor]:
module = getattr(descriptor, 'module_class', None) module_js = descriptor.module_class.get_javascript()
if module is None:
continue
js = module.get_javascript()
for filetype in ('coffee', 'js'): for filetype in ('coffee', 'js'):
for fragment in js.get(filetype, []): for fragment in js.get(filetype, []):
fragments.add((filetype, fragment)) fragments.add((filetype, fragment))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment