Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
70c6ce8d
Commit
70c6ce8d
authored
Jun 01, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ECOM-1678: Fix broken footer image URLs when using a CDN.
parent
a7c934c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletions
+30
-1
lms/djangoapps/branding/api.py
+10
-1
lms/djangoapps/branding/tests/test_views.py
+20
-0
No files found.
lms/djangoapps/branding/api.py
View file @
70c6ce8d
...
@@ -277,7 +277,7 @@ def _absolute_url(is_secure, url_path):
...
@@ -277,7 +277,7 @@ def _absolute_url(is_secure, url_path):
def
_absolute_url_staticfile
(
is_secure
,
name
):
def
_absolute_url_staticfile
(
is_secure
,
name
):
"""Construct an absolute URL
back
to a static resource on the site.
"""Construct an absolute URL to a static resource on the site.
Arguments:
Arguments:
is_secure (bool): If true, use HTTPS as the protocol.
is_secure (bool): If true, use HTTPS as the protocol.
...
@@ -288,4 +288,13 @@ def _absolute_url_staticfile(is_secure, name):
...
@@ -288,4 +288,13 @@ def _absolute_url_staticfile(is_secure, name):
"""
"""
url_path
=
staticfiles_storage
.
url
(
name
)
url_path
=
staticfiles_storage
.
url
(
name
)
# In production, the static files URL will be an absolute
# URL pointing to a CDN. If this happens, we can just
# return the URL.
if
urlparse
.
urlparse
(
url_path
)
.
netloc
:
return
url_path
# For local development, the returned URL will be relative,
# so we need to make it absolute.
return
_absolute_url
(
is_secure
,
url_path
)
return
_absolute_url
(
is_secure
,
url_path
)
lms/djangoapps/branding/tests/test_views.py
View file @
70c6ce8d
...
@@ -102,6 +102,26 @@ class TestFooter(TestCase):
...
@@ -102,6 +102,26 @@ class TestFooter(TestCase):
# Copyright
# Copyright
self
.
assertIn
(
"copyright"
,
json_data
)
self
.
assertIn
(
"copyright"
,
json_data
)
def
test_absolute_urls_with_cdn
(
self
):
self
.
_set_feature_flag
(
True
)
# 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
):
resp
=
self
.
_get_footer
()
self
.
assertEqual
(
resp
.
status_code
,
200
)
json_data
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
json_data
[
"logo_image"
],
cdn_url
)
for
link
in
json_data
[
"mobile_links"
]:
self
.
assertEqual
(
link
[
"url"
],
cdn_url
)
@ddt.data
(
@ddt.data
(
(
"en"
,
"registered trademarks"
),
(
"en"
,
"registered trademarks"
),
(
"eo"
,
u"régïstéréd trädémärks"
),
# Dummy language string
(
"eo"
,
u"régïstéréd trädémärks"
),
# Dummy language string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment