Merge pull request #8282 from Stanford-Online/giulio/default-course-about-images
Default "Course About" image
This commit is contained in:
@@ -126,10 +126,9 @@ def course_image_url(course):
|
||||
url += '/' + course.course_image
|
||||
else:
|
||||
url += '/images/course_image.jpg'
|
||||
elif course.course_image == '':
|
||||
# if course_image is empty the url will be blank as location
|
||||
# of the course_image does not exist
|
||||
url = ''
|
||||
elif not course.course_image:
|
||||
# if course_image is empty, use the default image url from settings
|
||||
url = settings.STATIC_URL + settings.DEFAULT_COURSE_ABOUT_IMAGE_URL
|
||||
else:
|
||||
loc = StaticContent.compute_location(course.id, course.course_image)
|
||||
url = StaticContent.serialize_asset_key_with_slash(loc)
|
||||
|
||||
@@ -794,16 +794,19 @@ class TestHtmlModifiers(ModuleStoreTestCase):
|
||||
self.assertTrue(url.startswith('/static/toy_course_dir/'))
|
||||
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)
|
||||
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.course_image = ''
|
||||
|
||||
url = course_image_url(self.course)
|
||||
self.assertEqual('', url)
|
||||
self.assertEqual('static/test.png', url)
|
||||
|
||||
def test_get_course_info_section(self):
|
||||
self.course.static_asset_path = "toy_course_dir"
|
||||
|
||||
@@ -131,6 +131,9 @@ if STATIC_URL_BASE:
|
||||
if not STATIC_URL.endswith("/"):
|
||||
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 = ENV_TOKENS.get('MEDIA_ROOT', MEDIA_ROOT)
|
||||
MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', MEDIA_URL)
|
||||
|
||||
@@ -843,6 +843,7 @@ STATICFILES_DIRS = [
|
||||
]
|
||||
|
||||
FAVICON_PATH = 'images/favicon.ico'
|
||||
DEFAULT_COURSE_ABOUT_IMAGE_URL = 'images/pencils.jpg'
|
||||
|
||||
# User-uploaded content
|
||||
MEDIA_ROOT = '/edx/var/edxapp/media/'
|
||||
|
||||
BIN
lms/static/images/pencils.jpg
Normal file
BIN
lms/static/images/pencils.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user