diff --git a/cms/static/js/views/course_info_edit.js b/cms/static/js/views/course_info_edit.js index ecd9ebe78d..38d2c78576 100644 --- a/cms/static/js/views/course_info_edit.js +++ b/cms/static/js/views/course_info_edit.js @@ -34,16 +34,8 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ }, initialize: function() { - var self = this; - // instantiates an editor template for each update in the collection - window.templateLoader.loadRemoteTemplate("course_info_update", - // TODO Where should the template reside? how to use the static.url to create the path? - "/static/client_templates/course_info_update.html", - function (raw_template) { - self.template = _.template(raw_template); - self.render(); - } - ); + this.template = _.template($("#course_info_update-tpl").text()); + this.render(); // when the client refetches the updates as a whole, re-render them this.listenTo(this.collection, 'reset', this.render); }, @@ -241,16 +233,11 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({ }, initialize: function() { + this.template = _.template($("#course_info_handouts-tpl").text()); var self = this; this.model.fetch({ complete: function() { - window.templateLoader.loadRemoteTemplate("course_info_handouts", - "/static/client_templates/course_info_handouts.html", - function (raw_template) { - self.template = _.template(raw_template); - self.render(); - } - ); + self.render(); }, reset: true }); diff --git a/cms/static/js/views/settings/advanced_view.js b/cms/static/js/views/settings/advanced_view.js index 90e84adf2b..5ae0c19570 100644 --- a/cms/static/js/views/settings/advanced_view.js +++ b/cms/static/js/views/settings/advanced_view.js @@ -11,16 +11,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ // TODO enable/disable save based on validation (currently enabled whenever there are changes) }, initialize : function() { - var self = this; - // instantiates an editor template for each update in the collection - window.templateLoader.loadRemoteTemplate("advanced_entry", - "/static/client_templates/advanced_entry.html", - function (raw_template) { - self.template = _.template(raw_template); - self.render(); - } - ); + this.template = _.template($("#advanced_entry-tpl").text()); this.listenTo(this.model, 'invalid', this.handleValidationError); + this.render(); }, render: function() { // catch potential outside call before template loaded @@ -56,7 +49,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ CodeMirror.fromTextArea(textarea, { mode: "application/json", lineNumbers: false, lineWrapping: false, onChange: function(instance, changeobj) { - instance.save() + instance.save(); // this event's being called even when there's no change :-( if (instance.getValue() !== oldValue) { var message = gettext("Your changes will not take effect until you save your progress. Take care with key and value formatting, as validation is not implemented."); @@ -105,8 +98,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ // call validateKey on each to ensure proper format // check for dupes var self = this; - this.model.save({}, - { + this.model.save({}, { success : function() { self.render(); var title = gettext("Your policy changes have been saved."); diff --git a/cms/templates/course_info.html b/cms/templates/course_info.html index dcfffd1d5a..03f4c35d14 100644 --- a/cms/templates/course_info.html +++ b/cms/templates/course_info.html @@ -6,9 +6,15 @@ <%block name="title">${_("Course Updates")} <%block name="bodyclass">is-signedin course course-info updates +<%block name="header_extras"> +% for template_name in ["course_info_update", "course_info_handouts"]: + +% endfor + <%block name="jsextra"> - diff --git a/cms/templates/js/advanced_entry.underscore b/cms/templates/js/advanced_entry.underscore new file mode 100644 index 0000000000..26b1a386f6 --- /dev/null +++ b/cms/templates/js/advanced_entry.underscore @@ -0,0 +1,11 @@ +
  • +
    + + +
    + +
    + + +
    +
  • diff --git a/cms/static/client_templates/course_info_handouts.html b/cms/templates/js/course_info_handouts.underscore similarity index 100% rename from cms/static/client_templates/course_info_handouts.html rename to cms/templates/js/course_info_handouts.underscore diff --git a/cms/static/client_templates/course_info_update.html b/cms/templates/js/course_info_update.underscore similarity index 100% rename from cms/static/client_templates/course_info_update.html rename to cms/templates/js/course_info_update.underscore diff --git a/cms/templates/settings_advanced.html b/cms/templates/settings_advanced.html index e1b1913c87..0409b1a9e4 100644 --- a/cms/templates/settings_advanced.html +++ b/cms/templates/settings_advanced.html @@ -1,15 +1,17 @@ -<%! from django.utils.translation import ugettext as _ %> <%inherit file="base.html" /> +<%namespace name='static' file='static_content.html'/> <%! from django.core.urlresolvers import reverse %> +<%! from django.utils.translation import ugettext as _ %> +<%! from contentstore import utils %> <%block name="title">${_("Advanced Settings")} <%block name="bodyclass">is-signedin course advanced settings -<%namespace name='static' file='static_content.html'/> -<%! -from contentstore import utils -%> - <%block name="jsextra"> +% for template_name in ["advanced_entry"]: + +% endfor diff --git a/common/djangoapps/mitxmako/shortcuts.py b/common/djangoapps/mitxmako/shortcuts.py index 7f7c3f9ebe..3c68fa85be 100644 --- a/common/djangoapps/mitxmako/shortcuts.py +++ b/common/djangoapps/mitxmako/shortcuts.py @@ -92,9 +92,10 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'): return template.render_unicode(**context_dictionary) -def render_to_response(template_name, dictionary, context_instance=None, namespace='main', **kwargs): +def render_to_response(template_name, dictionary=None, context_instance=None, namespace='main', **kwargs): """ Returns a HttpResponse whose content is filled with the result of calling lookup.get_template(args[0]).render with the passed arguments. """ + dictionary = dictionary or {} return HttpResponse(render_to_string(template_name, dictionary, context_instance, namespace), **kwargs)