From fefda5db62acbfb47cbdf6f50a14bd2ad4f6253a Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2012 16:09:34 -0400 Subject: [PATCH] Only munge /static/ urls in module html to point to course static files if they don't exist in the global static locations --- common/djangoapps/static_replace.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/djangoapps/static_replace.py b/common/djangoapps/static_replace.py index 70031cc754..f9660e7f5e 100644 --- a/common/djangoapps/static_replace.py +++ b/common/djangoapps/static_replace.py @@ -9,8 +9,11 @@ def replace(static_url, prefix=None): prefix = prefix + '/' quote = static_url.group('quote') - url = staticfiles_storage.url(prefix + static_url.group('rest')) - return "".join([quote, url, quote]) + if staticfiles_storage.exists(static_url.group('rest')): + return static_url.group(0) + else: + url = staticfiles_storage.url(prefix + static_url.group('rest')) + return "".join([quote, url, quote]) def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'): @@ -18,9 +21,9 @@ def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'): return replace(static_url, staticfiles_prefix) return re.sub(r""" - (?x) # flags=re.VERBOSE - (?P\\?['"]) # the opening quotes - {prefix} # the prefix - (?P.*?) # everything else in the url - (?P=quote) # the first matching closing quote + (?x) # flags=re.VERBOSE + (?P\\?['"]) # the opening quotes + (?P{prefix}) # the prefix + (?P.*?) # everything else in the url + (?P=quote) # the first matching closing quote """.format(prefix=replace_prefix), replace_url, text)