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
31646e4a
Commit
31646e4a
authored
Nov 24, 2015
by
Dan Powell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't render unconfigured marketing links in CMS footer.
parent
86227e77
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
cms/templates/widgets/footer.html
+6
-0
common/djangoapps/edxmako/shortcuts.py
+26
-0
common/djangoapps/edxmako/tests.py
+28
-0
No files found.
cms/templates/widgets/footer.html
View file @
31646e4a
...
@@ -11,16 +11,22 @@ from django.core.urlresolvers import reverse
...
@@ -11,16 +11,22 @@ from django.core.urlresolvers import reverse
<p>
©
${settings.COPYRIGHT_YEAR}
<a
data-rel=
"edx.org"
href=
"${marketing_link('ROOT')}"
rel=
"external"
>
${settings.PLATFORM_NAME}
</a>
.
</p>
<p>
©
${settings.COPYRIGHT_YEAR}
<a
data-rel=
"edx.org"
href=
"${marketing_link('ROOT')}"
rel=
"external"
>
${settings.PLATFORM_NAME}
</a>
.
</p>
</div>
</div>
% if is_any_marketing_link_set(['TOS', 'PRIVACY']):
<nav
class=
"nav-peripheral"
>
<nav
class=
"nav-peripheral"
>
<ol>
<ol>
% if is_marketing_link_set('TOS'):
<li
class=
"nav-item nav-peripheral-tos"
>
<li
class=
"nav-item nav-peripheral-tos"
>
<a
data-rel=
"edx.org"
href=
"${marketing_link('TOS')}"
>
${_("Terms of Service")}
</a>
<a
data-rel=
"edx.org"
href=
"${marketing_link('TOS')}"
>
${_("Terms of Service")}
</a>
</li>
</li>
% endif
% if is_marketing_link_set('PRIVACY'):
<li
class=
"nav-item nav-peripheral-pp"
>
<li
class=
"nav-item nav-peripheral-pp"
>
<a
data-rel=
"edx.org"
href=
"${marketing_link('PRIVACY')}"
>
${_("Privacy Policy")}
</a>
<a
data-rel=
"edx.org"
href=
"${marketing_link('PRIVACY')}"
>
${_("Privacy Policy")}
</a>
</li>
</li>
% endif
</ol>
</ol>
</nav>
</nav>
% endif
</div>
</div>
<div
class=
"footer-content-secondary"
aria-label=
"{_('Legal')}"
>
<div
class=
"footer-content-secondary"
aria-label=
"{_('Legal')}"
>
...
...
common/djangoapps/edxmako/shortcuts.py
View file @
31646e4a
...
@@ -57,6 +57,30 @@ def marketing_link(name):
...
@@ -57,6 +57,30 @@ def marketing_link(name):
return
'#'
return
'#'
def
is_any_marketing_link_set
(
names
):
"""
Returns a boolean if any given named marketing links are configured.
"""
return
any
(
is_marketing_link_set
(
name
)
for
name
in
names
)
def
is_marketing_link_set
(
name
):
"""
Returns a boolean if a given named marketing link is configured.
"""
enable_mktg_site
=
microsite
.
get_value
(
'ENABLE_MKTG_SITE'
,
settings
.
FEATURES
.
get
(
'ENABLE_MKTG_SITE'
,
False
)
)
if
enable_mktg_site
:
return
name
in
settings
.
MKTG_URLS
else
:
return
name
in
settings
.
MKTG_URL_LINK_MAP
def
marketing_link_context_processor
(
request
):
def
marketing_link_context_processor
(
request
):
"""
"""
A django context processor to give templates access to marketing URLs
A django context processor to give templates access to marketing URLs
...
@@ -112,6 +136,8 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'):
...
@@ -112,6 +136,8 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'):
context_instance
[
'settings'
]
=
settings
context_instance
[
'settings'
]
=
settings
context_instance
[
'EDX_ROOT_URL'
]
=
settings
.
EDX_ROOT_URL
context_instance
[
'EDX_ROOT_URL'
]
=
settings
.
EDX_ROOT_URL
context_instance
[
'marketing_link'
]
=
marketing_link
context_instance
[
'marketing_link'
]
=
marketing_link
context_instance
[
'is_any_marketing_link_set'
]
=
is_any_marketing_link_set
context_instance
[
'is_marketing_link_set'
]
=
is_marketing_link_set
# In various testing contexts, there might not be a current request context.
# In various testing contexts, there might not be a current request context.
request_context
=
get_template_request_context
()
request_context
=
get_template_request_context
()
...
...
common/djangoapps/edxmako/tests.py
View file @
31646e4a
...
@@ -14,6 +14,8 @@ from edxmako.middleware import get_template_request_context
...
@@ -14,6 +14,8 @@ from edxmako.middleware import get_template_request_context
from
edxmako
import
add_lookup
,
LOOKUP
from
edxmako
import
add_lookup
,
LOOKUP
from
edxmako.shortcuts
import
(
from
edxmako.shortcuts
import
(
marketing_link
,
marketing_link
,
is_marketing_link_set
,
is_any_marketing_link_set
,
render_to_string
,
render_to_string
,
open_source_footer_context_processor
open_source_footer_context_processor
)
)
...
@@ -41,6 +43,32 @@ class ShortcutsTests(UrlResetMixin, TestCase):
...
@@ -41,6 +43,32 @@ class ShortcutsTests(UrlResetMixin, TestCase):
link
=
marketing_link
(
'ABOUT'
)
link
=
marketing_link
(
'ABOUT'
)
self
.
assertEquals
(
link
,
expected_link
)
self
.
assertEquals
(
link
,
expected_link
)
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URL_LINK_MAP
=
{
'ABOUT'
:
'login'
})
def
test_is_marketing_link_set
(
self
):
# test marketing site on
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_MKTG_SITE'
:
True
}):
self
.
assertTrue
(
is_marketing_link_set
(
'ABOUT'
))
self
.
assertFalse
(
is_marketing_link_set
(
'NOT_CONFIGURED'
))
# test marketing site off
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_MKTG_SITE'
:
False
}):
self
.
assertTrue
(
is_marketing_link_set
(
'ABOUT'
))
self
.
assertFalse
(
is_marketing_link_set
(
'NOT_CONFIGURED'
))
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URL_LINK_MAP
=
{
'ABOUT'
:
'login'
})
def
test_is_any_marketing_link_set
(
self
):
# test marketing site on
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_MKTG_SITE'
:
True
}):
self
.
assertTrue
(
is_any_marketing_link_set
([
'ABOUT'
]))
self
.
assertTrue
(
is_any_marketing_link_set
([
'ABOUT'
,
'NOT_CONFIGURED'
]))
self
.
assertFalse
(
is_any_marketing_link_set
([
'NOT_CONFIGURED'
]))
# test marketing site off
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_MKTG_SITE'
:
False
}):
self
.
assertTrue
(
is_any_marketing_link_set
([
'ABOUT'
]))
self
.
assertTrue
(
is_any_marketing_link_set
([
'ABOUT'
,
'NOT_CONFIGURED'
]))
self
.
assertFalse
(
is_any_marketing_link_set
([
'NOT_CONFIGURED'
]))
@ddt.data
((
True
,
None
),
(
False
,
None
))
@ddt.data
((
True
,
None
),
(
False
,
None
))
@ddt.unpack
@ddt.unpack
def
test_edx_footer
(
self
,
expected_result
,
_
):
def
test_edx_footer
(
self
,
expected_result
,
_
):
...
...
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