Fix branding api get_logo_url return value
This commit is contained in:
@@ -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
|
||||
|
||||
23
lms/djangoapps/branding/tests/test_api.py
Normal file
23
lms/djangoapps/branding/tests/test_api.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# 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>
|
||||
|
||||
Reference in New Issue
Block a user