Commit ad5a98e4 by Davorin Šego

Merge pull request #8282 from Stanford-Online/giulio/default-course-about-images

Default "Course About" image
parents 796e4cb5 84f7aef9
...@@ -126,10 +126,9 @@ def course_image_url(course): ...@@ -126,10 +126,9 @@ def course_image_url(course):
url += '/' + course.course_image url += '/' + course.course_image
else: else:
url += '/images/course_image.jpg' url += '/images/course_image.jpg'
elif course.course_image == '': elif not course.course_image:
# if course_image is empty the url will be blank as location # if course_image is empty, use the default image url from settings
# of the course_image does not exist url = settings.STATIC_URL + settings.DEFAULT_COURSE_ABOUT_IMAGE_URL
url = ''
else: else:
loc = StaticContent.compute_location(course.id, course.course_image) loc = StaticContent.compute_location(course.id, course.course_image)
url = StaticContent.serialize_asset_key_with_slash(loc) url = StaticContent.serialize_asset_key_with_slash(loc)
......
...@@ -794,16 +794,19 @@ class TestHtmlModifiers(ModuleStoreTestCase): ...@@ -794,16 +794,19 @@ class TestHtmlModifiers(ModuleStoreTestCase):
self.assertTrue(url.startswith('/static/toy_course_dir/')) self.assertTrue(url.startswith('/static/toy_course_dir/'))
self.course.static_asset_path = "" self.course.static_asset_path = ""
@override_settings(DEFAULT_COURSE_ABOUT_IMAGE_URL='test.png')
@override_settings(STATIC_URL='static/')
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_course_image_for_split_course(self, store): def test_course_image_for_split_course(self, store):
""" """
for split courses if course_image is empty then course_image_url will be blank for split courses if course_image is empty then course_image_url will be
the default image url defined in settings
""" """
self.course = CourseFactory.create(default_store=store) self.course = CourseFactory.create(default_store=store)
self.course.course_image = '' self.course.course_image = ''
url = course_image_url(self.course) url = course_image_url(self.course)
self.assertEqual('', url) self.assertEqual('static/test.png', url)
def test_get_course_info_section(self): def test_get_course_info_section(self):
self.course.static_asset_path = "toy_course_dir" self.course.static_asset_path = "toy_course_dir"
......
...@@ -131,6 +131,9 @@ if STATIC_URL_BASE: ...@@ -131,6 +131,9 @@ if STATIC_URL_BASE:
if not STATIC_URL.endswith("/"): if not STATIC_URL.endswith("/"):
STATIC_URL += "/" STATIC_URL += "/"
# DEFAULT_COURSE_ABOUT_IMAGE_URL specifies the default image to show for courses that don't provide one
DEFAULT_COURSE_ABOUT_IMAGE_URL = ENV_TOKENS.get('DEFAULT_COURSE_ABOUT_IMAGE_URL', DEFAULT_COURSE_ABOUT_IMAGE_URL)
# MEDIA_ROOT specifies the directory where user-uploaded files are stored. # MEDIA_ROOT specifies the directory where user-uploaded files are stored.
MEDIA_ROOT = ENV_TOKENS.get('MEDIA_ROOT', MEDIA_ROOT) MEDIA_ROOT = ENV_TOKENS.get('MEDIA_ROOT', MEDIA_ROOT)
MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', MEDIA_URL) MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', MEDIA_URL)
......
...@@ -843,6 +843,7 @@ STATICFILES_DIRS = [ ...@@ -843,6 +843,7 @@ STATICFILES_DIRS = [
] ]
FAVICON_PATH = 'images/favicon.ico' FAVICON_PATH = 'images/favicon.ico'
DEFAULT_COURSE_ABOUT_IMAGE_URL = 'images/pencils.jpg'
# User-uploaded content # User-uploaded content
MEDIA_ROOT = '/edx/var/edxapp/media/' MEDIA_ROOT = '/edx/var/edxapp/media/'
......
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