From 96eb16cd729ce65df69b3f70d4b8d95341d8a650 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 6 Feb 2013 10:08:20 -0500 Subject: [PATCH] Make local dev work by trying checking staticfiles_storage for both the course_prefixed and non-course_prefixed urls --- common/djangoapps/static_replace/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common/djangoapps/static_replace/__init__.py b/common/djangoapps/static_replace/__init__.py index cfef798bdf..4833f5ef96 100644 --- a/common/djangoapps/static_replace/__init__.py +++ b/common/djangoapps/static_replace/__init__.py @@ -76,18 +76,19 @@ def replace_static_urls(text, data_directory, course_namespace=None): # course_namespace is not None, then use studio style urls if course_namespace is not None and not isinstance(modulestore(), XMLModuleStore): url = StaticContent.convert_legacy_static_url(rest, course_namespace) - # If we're in debug mode, and the file as requested exists, then don't change the links - elif (settings.DEBUG and finders.find(rest, True)): - return original - # Otherwise, look the file up in staticfiles_storage without the data directory + # Otherwise, look the file up in staticfiles_storage, and append the data directory if needed else: + course_path = "/".join((data_directory, rest)) try: - url = staticfiles_storage.url(rest) + if staticfiles_storage.exists(rest): + url = staticfiles_storage.url(rest) + else: + url = staticfiles_storage.url(course_path) # And if that fails, assume that it's course content, and add manually data directory except Exception as err: log.warning("staticfiles_storage couldn't find path {0}: {1}".format( rest, str(err))) - url = "".join([prefix, data_directory, '/', rest]) + url = "".join([prefix, course_path]) return "".join([quote, url, quote])