Commit bfae8206 by Saleem Latif Committed by GitHub

Merge pull request #12987 from edx/saleem-latif/branding-logo-url-fix

Fix branding api get_logo_url return value
parents 07467a5b 5503285f
......@@ -367,18 +367,20 @@ def get_base_url(is_secure):
return _absolute_url(is_secure=is_secure, url_path="")
def get_logo_url():
def get_logo_url(is_secure=True):
"""
Return the url for the branded logo image to be used
Arguments:
is_secure (bool): If true, use HTTPS as the protocol.
"""
# if the MicrositeConfiguration has a value for the logo_image_url
# let's use that
image_url = microsite.get_value('logo_image_url')
if image_url:
return '{static_url}{image_url}'.format(
static_url=settings.STATIC_URL,
image_url=image_url
return _absolute_url_staticfile(
is_secure=is_secure,
name=image_url,
)
# otherwise, use the legacy means to configure this
......
# encoding: utf-8
"""Tests of Branding API """
from django.test import TestCase
import mock
from branding.api import get_logo_url
class TestHeader(TestCase):
"""Test API end-point for retrieving the header. """
def test_cdn_urls_for_logo(self):
# Ordinarily, we'd use `override_settings()` to override STATIC_URL,
# which is what the staticfiles storage backend is using to construct the URL.
# Unfortunately, other parts of the system are caching this value on module
# load, which can cause other tests to fail. To ensure that this change
# doesn't affect other tests, we patch the `url()` method directly instead.
cdn_url = "http://cdn.example.com/static/image.png"
with mock.patch('branding.api.staticfiles_storage.url', return_value=cdn_url):
logo_url = get_logo_url()
self.assertEqual(logo_url, cdn_url)
......@@ -571,7 +571,7 @@ def get_certificate_header_context(is_secure=True):
data returned should be customized according to the microsite settings
"""
data = dict(
logo_src=branding_api.get_logo_url(),
logo_src=branding_api.get_logo_url(is_secure),
logo_url=branding_api.get_base_url(is_secure),
)
......
......@@ -53,7 +53,7 @@ site_status_msg = get_site_status_msg(course_id)
<h1 class="logo">
<a href="${marketing_link('ROOT')}">
<%block name="navigation_logo">
<img src="${static.url(branding_api.get_logo_url())}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
<img src="${branding_api.get_logo_url(is_secure)}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
</%block>
</a>
</h1>
......
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