Skip to content

Commit

Permalink
Enable to configure the header logo openedx#470
Browse files Browse the repository at this point in the history
  • Loading branch information
hachiyanagi-ks committed Oct 29, 2015
1 parent 2d4405e commit 6f880cd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lms/djangoapps/branding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_logo_url():

# if the MicrositeConfiguration has a value for the logo_image_url
# let's use that
image_url = microsite.get_value('logo_image_url')
image_url = microsite.get_value('logo_image_url', getattr(settings, 'HEADER_LOGO_IMAGE', None))
if image_url:
return '{static_url}{image_url}'.format(
static_url=settings.STATIC_URL,
Expand Down
43 changes: 43 additions & 0 deletions lms/djangoapps/branding/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings
from django.test.utils import override_settings

import mock
import ddt
from config_models.models import cache
from branding import get_logo_url
from branding.models import BrandingApiConfig


Expand Down Expand Up @@ -233,3 +235,44 @@ def _set_is_edx_domain(self, is_edx_domain):
"""Configure whether this an EdX-controlled domain. """
with mock.patch.dict(settings.FEATURES, {'IS_EDX_DOMAIN': is_edx_domain}):
yield


def university_microsite_configuration():
return {
'university': 'test-university'
}


def logo_image_microsite_configuration():
return {
'university': 'test-university',
'logo_image_url': 'images/test-microsite-logo.png'
}


class LogoUrlTest(TestCase):
"""Tests for logo url"""

def _logo_url(self, path):
return settings.STATIC_URL + path

def test_default_logo(self):
self.assertEqual(self._logo_url('images/default-theme/logo.png'), get_logo_url())

@override_settings(FEATURES={"IS_EDX_DOMAIN":True})
def test_default_logo_edx_domain(self):
self.assertEqual(self._logo_url('images/edx-theme/edx-logo-77x36.png'), get_logo_url())

@override_settings(FEATURES={"IS_EDX_DOMAIN":True})
@mock.patch("microsite_configuration.microsite.get_configuration", university_microsite_configuration)
def test_university_logo(self):
self.assertEqual(self._logo_url('images/test-university-on-edx-logo.png'), get_logo_url())

@override_settings(HEADER_LOGO_IMAGE='images/test-header-logo-image.png')
def test_settings_header_logo_image(self):
self.assertEqual(self._logo_url('images/test-header-logo-image.png'), get_logo_url())

@override_settings(HEADER_LOGO_IMAGE='images/test-header-logo-image.png')
@mock.patch("microsite_configuration.microsite.get_configuration", logo_image_microsite_configuration)
def test_settings_header_logo_image_microsite(self):
self.assertEqual(self._logo_url('images/test-microsite-logo.png'), get_logo_url())
3 changes: 3 additions & 0 deletions lms/envs/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@
# Example: {'CN': 'http://api.xuetangx.com/edx/video?s3_url='}
VIDEO_CDN_URL = ENV_TOKENS.get('VIDEO_CDN_URL', {})

# Branded header
HEADER_LOGO_IMAGE = ENV_TOKENS.get('HEADER_LOGO_IMAGE', HEADER_LOGO_IMAGE)

# Branded footer
FOOTER_OPENEDX_URL = ENV_TOKENS.get('FOOTER_OPENEDX_URL', FOOTER_OPENEDX_URL)
FOOTER_OPENEDX_LOGO_IMAGE = ENV_TOKENS.get('FOOTER_OPENEDX_LOGO_IMAGE', FOOTER_OPENEDX_LOGO_IMAGE)
Expand Down
3 changes: 3 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,9 @@
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'


######################### Branded Header ###################################
HEADER_LOGO_IMAGE = None

######################### Branded Footer ###################################
# Constants for the footer used on the site and shared with other sites
# (such as marketing and the blog) via the branding API.
Expand Down

0 comments on commit 6f880cd

Please sign in to comment.