From 2aceb2e44a5e6aa487d1b246909ebbb567bdd659 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 29 Nov 2012 15:56:03 -0500 Subject: [PATCH] make sure when defining the course namespace in the replace url methods that we explicitly state the parameter name. There are some optional parameters and if we don't define the parameter name, it'll end put being interpreted as a different parameter --- common/djangoapps/static_replace.py | 1 + common/lib/xmodule/xmodule/capa_module.py | 4 ++-- lms/djangoapps/courseware/courses.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/static_replace.py b/common/djangoapps/static_replace.py index ee63e3cf93..e75362d784 100644 --- a/common/djangoapps/static_replace.py +++ b/common/djangoapps/static_replace.py @@ -60,6 +60,7 @@ def replace(static_url, prefix=None, course_namespace=None): def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/', course_namespace=None): + def replace_url(static_url): return replace(static_url, staticfiles_prefix, course_namespace = course_namespace) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 525cf0ba87..9922b1b8a0 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -347,7 +347,7 @@ class CapaModule(XModule): id=self.location.html_id(), ajax_url=self.system.ajax_url) + html + "" # now do the substitutions which are filesystem based, e.g. '/static/' prefixes - return self.system.replace_urls(html, self.metadata['data_dir'], self.location) + return self.system.replace_urls(html, self.metadata['data_dir'], course_namespace=self.location) def handle_ajax(self, dispatch, get): ''' @@ -451,7 +451,7 @@ class CapaModule(XModule): new_answers = dict() for answer_id in answers: try: - new_answer = {answer_id: self.system.replace_urls(answers[answer_id], self.metadata['data_dir'], self.location)} + new_answer = {answer_id: self.system.replace_urls(answers[answer_id], self.metadata['data_dir'], course_namespace=self.location)} except TypeError: log.debug('Unable to perform URL substitution on answers[%s]: %s' % (answer_id, answers[answer_id])) new_answer = {answer_id: answers[answer_id]} diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index f3e435e4dc..6de309076d 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -220,7 +220,7 @@ def get_course_syllabus_section(course, section_key): filepath = find_file(fs, dirs, section_key + ".html") with fs.open(filepath) as htmlFile: return replace_urls(htmlFile.read().decode('utf-8'), - course.metadata['data_dir'], course.location) + course.metadata['data_dir'], course_namespace=course.location) except ResourceNotFoundError: log.exception("Missing syllabus section {key} in course {url}".format( key=section_key, url=course.location.url()))