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
6fd960c8
Commit
6fd960c8
authored
Dec 03, 2015
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10733 from CredoReference/feature/EDX-21
Don't render unconfigured marketing links in CMS footer.
parents
d344d6f8
696e1962
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
10 deletions
+71
-10
AUTHORS
+1
-0
cms/templates/widgets/footer.html
+16
-10
common/djangoapps/edxmako/shortcuts.py
+26
-0
common/djangoapps/edxmako/tests.py
+28
-0
No files found.
AUTHORS
View file @
6fd960c8
...
@@ -257,3 +257,4 @@ Muhammad Rehan <muhammadrehan69@gmail.com>
...
@@ -257,3 +257,4 @@ Muhammad Rehan <muhammadrehan69@gmail.com>
Shawn Milochik <shawn@milochik.com>
Shawn Milochik <shawn@milochik.com>
Afeef Janjua <janjua.afeef@gmail.com>
Afeef Janjua <janjua.afeef@gmail.com>
Jacek Bzdak <jbzdak@gmail.com>
Jacek Bzdak <jbzdak@gmail.com>
Dan Powell <dan@abakas.com>
cms/templates/widgets/footer.html
View file @
6fd960c8
...
@@ -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>
<nav
class=
"nav-peripheral"
>
% if is_any_marketing_link_set(['TOS', 'PRIVACY']):
<ol>
<nav
class=
"nav-peripheral"
>
<li
class=
"nav-item nav-peripheral-tos"
>
<ol>
<a
data-rel=
"edx.org"
href=
"${marketing_link('TOS')}"
>
${_("Terms of Service")}
</a>
% if is_marketing_link_set('TOS'):
</li>
<li
class=
"nav-item nav-peripheral-tos"
>
<li
class=
"nav-item nav-peripheral-pp"
>
<a
data-rel=
"edx.org"
href=
"${marketing_link('TOS')}"
>
${_("Terms of Service")}
</a>
<a
data-rel=
"edx.org"
href=
"${marketing_link('PRIVACY')}"
>
${_("Privacy Policy")}
</a>
</li>
</li>
% endif
</ol>
% if is_marketing_link_set('PRIVACY'):
</nav>
<li
class=
"nav-item nav-peripheral-pp"
>
<a
data-rel=
"edx.org"
href=
"${marketing_link('PRIVACY')}"
>
${_("Privacy Policy")}
</a>
</li>
% endif
</ol>
</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 @
6fd960c8
...
@@ -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 @
6fd960c8
...
@@ -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