Commit f247adc4 by Carson Gee

Merge pull request #1 from edx/ned/tweaks-for-pr-3464

Simple fixes
parents ff156438 2f7adda0
......@@ -326,10 +326,12 @@ class TestMongoModuleStore(object):
self.content_store.find(location)
root_dir = path(mkdtemp())
export_to_xml(self.store, self.content_store, course_location, root_dir, 'test_export')
assert_true(path(root_dir / 'test_export/static/images/course_image.jpg').isfile())
assert_true(path(root_dir / 'test_export/static/images_course_image.jpg').isfile())
shutil.rmtree(root_dir)
try:
export_to_xml(self.store, self.content_store, course_location, root_dir, 'test_export')
assert_true(path(root_dir / 'test_export/static/images/course_image.jpg').isfile())
assert_true(path(root_dir / 'test_export/static/images_course_image.jpg').isfile())
finally:
shutil.rmtree(root_dir)
def test_export_course_image_nondefault(self):
"""
......@@ -340,10 +342,12 @@ class TestMongoModuleStore(object):
assert_true(course.course_image, 'just_a_test.jpg')
root_dir = path(mkdtemp())
export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export')
assert_true(path(root_dir / 'test_export/static/just_a_test.jpg').isfile())
assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile())
shutil.rmtree(root_dir)
try:
export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export')
assert_true(path(root_dir / 'test_export/static/just_a_test.jpg').isfile())
assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile())
finally:
shutil.rmtree(root_dir)
def test_course_without_image(self):
"""
......@@ -352,10 +356,12 @@ class TestMongoModuleStore(object):
"""
course = self.get_course_by_id('edX/simple_with_draft/2012_Fall')
root_dir = path(mkdtemp())
export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export')
assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile())
assert_false(path(root_dir / 'test_export/static/images_course_image.jpg').isfile())
shutil.rmtree(root_dir)
try:
export_to_xml(self.store, self.content_store, course.location, root_dir, 'test_export')
assert_false(path(root_dir / 'test_export/static/images/course_image.jpg').isfile())
assert_false(path(root_dir / 'test_export/static/images_course_image.jpg').isfile())
finally:
shutil.rmtree(root_dir)
......
......@@ -110,14 +110,15 @@ def course_image_url(course):
# set different than the default, return that path so that
# courses can use custom course image paths, otherwise just
# return the default static path.
url = '/static/' + (course.static_asset_path or getattr(course, 'data_dir', ''))
if hasattr(course, 'course_image') and course.course_image != course.fields['course_image'].default:
return '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) + '/' + course.course_image
url += '/' + course.course_image
else:
return '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) + "/images/course_image.jpg"
url += '/images/course_image.jpg'
else:
loc = StaticContent.compute_location(course.location.org, course.location.course, course.course_image)
_path = StaticContent.get_url_path_from_location(loc)
return _path
url = StaticContent.get_url_path_from_location(loc)
return url
def find_file(filesystem, dirs, filename):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment