From 799ad92ecd728170fbe704bd49047235f97ff12c Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 13 May 2013 10:39:39 -0400 Subject: [PATCH 01/19] Add documentation of xmodule template files --- common/lib/xmodule/xmodule/templates.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/templates.py b/common/lib/xmodule/xmodule/templates.py index f4e37ab0d5..6479b3df24 100644 --- a/common/lib/xmodule/xmodule/templates.py +++ b/common/lib/xmodule/xmodule/templates.py @@ -4,8 +4,18 @@ These templates are used by the CMS to provide baseline content that can be cloned when adding new modules to a course. `Template`s are defined in x_module. They contain 3 attributes: - metadata: A dictionary with the template metadata - data: A JSON value that defines the template content + metadata: A dictionary with the template metadata. This should contain + any values for fields + * with scope Scope.settings + * that have values different than the field defaults + * and that are to be editable in Studio + data: A JSON value that defines the template content. This should be a dictionary + containing values for fields + * with scope Scope.content + * that have values different than the field defaults + * and that are to be editable in Studio + or, if the module uses a single Scope.content String field named `data`, this + should be a string containing the contents of that field children: A list of Location urls that define the template children Templates are defined on XModuleDescriptor types, in the template attribute. From c8970cafee417ca59d1914efefb6987171ed4cd9 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 14 May 2013 11:29:41 -0400 Subject: [PATCH 02/19] Add comment service request time logging to Datadog --- lms/lib/comment_client/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lms/lib/comment_client/utils.py b/lms/lib/comment_client/utils.py index 53bdd462ad..fce9516739 100644 --- a/lms/lib/comment_client/utils.py +++ b/lms/lib/comment_client/utils.py @@ -1,3 +1,4 @@ +from dogapi import dog_stats_api import json import logging import requests @@ -32,10 +33,11 @@ def perform_request(method, url, data_or_params=None, *args, **kwargs): data_or_params = {} data_or_params['api_key'] = settings.API_KEY try: - if method in ['post', 'put', 'patch']: - response = requests.request(method, url, data=data_or_params, timeout=5) - else: - response = requests.request(method, url, params=data_or_params, timeout=5) + with dog_stats_api.timer('comment_client.request.time'): + if method in ['post', 'put', 'patch']: + response = requests.request(method, url, data=data_or_params, timeout=5) + else: + response = requests.request(method, url, params=data_or_params, timeout=5) except Exception as err: # remove API key if it is in the params if 'api_key' in data_or_params: From 87cc4fab5ac6ee12edcfadac94b47e7e6371dcf0 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 14 May 2013 13:20:55 -0400 Subject: [PATCH 03/19] Add tags to comment service request Datadog timer --- lms/lib/comment_client/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lms/lib/comment_client/utils.py b/lms/lib/comment_client/utils.py index fce9516739..1ce03ed3c7 100644 --- a/lms/lib/comment_client/utils.py +++ b/lms/lib/comment_client/utils.py @@ -31,9 +31,14 @@ def merge_dict(dic1, dic2): def perform_request(method, url, data_or_params=None, *args, **kwargs): if data_or_params is None: data_or_params = {} + tags = [ + "{k}:{v}".format(k=k, v=v) + for (k, v) in data_or_params.items() + [("method", method), ("url", url)] + if k != 'api_key' + ] data_or_params['api_key'] = settings.API_KEY try: - with dog_stats_api.timer('comment_client.request.time'): + with dog_stats_api.timer('comment_client.request.time', tags=tags): if method in ['post', 'put', 'patch']: response = requests.request(method, url, data=data_or_params, timeout=5) else: From e9a8f408bffc1c64e192f8d39401d9c5f9697a6b Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 14 May 2013 16:43:41 -0400 Subject: [PATCH 04/19] Add {reset: true} to all collection.fetch() calls This is to fix a bug with the Backbone 1.0 upgrade; some views were listening to reset events that were not longer getting fired --- cms/static/js/views/checklists_view.js | 1 + cms/static/js/views/course_info_edit.js | 43 +++++++++++-------- cms/static/js/views/settings/advanced_view.js | 1 + cms/templates/course_info.html | 8 ++-- cms/templates/settings.html | 18 ++++---- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/cms/static/js/views/checklists_view.js b/cms/static/js/views/checklists_view.js index 1ae29f99d5..b2727e58f7 100644 --- a/cms/static/js/views/checklists_view.js +++ b/cms/static/js/views/checklists_view.js @@ -22,6 +22,7 @@ CMS.Views.Checklists = Backbone.View.extend({ } ); }, + reset: true, error: CMS.ServerError } ); diff --git a/cms/static/js/views/course_info_edit.js b/cms/static/js/views/course_info_edit.js index 50793c5f1e..9554b0d7c3 100644 --- a/cms/static/js/views/course_info_edit.js +++ b/cms/static/js/views/course_info_edit.js @@ -160,11 +160,17 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ var targetModel = this.eventModel(event); this.modelDom(event).remove(); var cacheThis = this; - targetModel.destroy({success : function (model, response) { - cacheThis.collection.fetch({success : function() {cacheThis.render();}, - error : CMS.ServerError}); - }, - error : CMS.ServerError + targetModel.destroy({ + success: function (model, response) { + cacheThis.collection.fetch({ + success: function() { + cacheThis.render(); + }, + reset: true, + error: CMS.ServerError + }); + }, + error : CMS.ServerError }); }, @@ -238,20 +244,19 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({ initialize: function() { 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(); - } - ); - }, - error : CMS.ServerError - } - ); + 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(); + } + ); + }, + reset: true, + error: CMS.ServerError + }); }, render: function () { diff --git a/cms/static/js/views/settings/advanced_view.js b/cms/static/js/views/settings/advanced_view.js index c1392831b8..bef908601b 100644 --- a/cms/static/js/views/settings/advanced_view.js +++ b/cms/static/js/views/settings/advanced_view.js @@ -155,6 +155,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({ self.model.clear({silent : true}); self.model.fetch({ success : function() { self.render(); }, + reset: true, error : CMS.ServerError }); }, diff --git a/cms/templates/course_info.html b/cms/templates/course_info.html index cbf436ecc5..55042ee843 100644 --- a/cms/templates/course_info.html +++ b/cms/templates/course_info.html @@ -16,18 +16,18 @@ - + - + - \ No newline at end of file + diff --git a/cms/templates/index.html b/cms/templates/index.html index 0f6e982b1d..007033623d 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -37,9 +37,7 @@ <%block name="content">
-
-

${_("My Courses")}

-
+

${_("My Courses")}

% if user.is_active: