From b3dcc140b797f4ff5ac66fa2d0fdbedac3c48666 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Mon, 26 Nov 2012 14:22:13 -0500 Subject: [PATCH] made a special 'module preview' view for Static Tabs in the CMS. Per Tom, he'd like just the Display Name to show up in the static tab editor until the end-user clicks the Edit button --- cms/djangoapps/contentstore/views.py | 19 ++++++++++++++----- cms/templates/xmodule_tab_display.html | 3 +++ common/djangoapps/xmodule_modifiers.py | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 cms/templates/xmodule_tab_display.html diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index c8f8e8152d..8cc9886396 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -496,11 +496,20 @@ def load_preview_module(request, preview_id, descriptor, instance_state, shared_ error_msg=exc_info_to_str(sys.exc_info()) ).xmodule_constructor(system)(None, None) - module.get_html = wrap_xmodule( - module.get_html, - module, - "xmodule_display.html", - ) + # cdodge: Special case + if module.location.category == 'static_tab': + module.get_html = wrap_xmodule( + module.get_html, + module, + "xmodule_tab_display.html", + ) + else: + module.get_html = wrap_xmodule( + module.get_html, + module, + "xmodule_display.html", + ) + module.get_html = replace_static_urls( module.get_html, module.metadata.get('data_dir', module.location.course), diff --git a/cms/templates/xmodule_tab_display.html b/cms/templates/xmodule_tab_display.html new file mode 100644 index 0000000000..3b6ecc9593 --- /dev/null +++ b/cms/templates/xmodule_tab_display.html @@ -0,0 +1,3 @@ +
+ ${display_name} +
diff --git a/common/djangoapps/xmodule_modifiers.py b/common/djangoapps/xmodule_modifiers.py index cda3d013cd..5c19a2f1d7 100644 --- a/common/djangoapps/xmodule_modifiers.py +++ b/common/djangoapps/xmodule_modifiers.py @@ -21,6 +21,7 @@ def wrap_xmodule(get_html, module, template, context=None): module: An XModule template: A template that takes the variables: content: the results of get_html, + display_name: the display name of the xmodule, if available (None otherwise) class_: the module class name module_name: the js_module_name of the module """ @@ -31,6 +32,7 @@ def wrap_xmodule(get_html, module, template, context=None): def _get_html(): context.update({ 'content': get_html(), + 'display_name' : module.metadata.get('display_name') if module.metadata is not None else None, 'class_': module.__class__.__name__, 'module_name': module.js_module_name })