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
8eeb091d
Commit
8eeb091d
authored
Sep 02, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5036 from edx/sanchez/fix_django_header_tests
Sanchez/fix django header tests
parents
9a0d9f70
2f4fb305
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
20 deletions
+89
-20
common/djangoapps/edxmako/shortcuts.py
+26
-0
common/djangoapps/edxmako/tests.py
+28
-2
lms/djangoapps/courseware/tests/test_footer.py
+14
-14
lms/envs/common.py
+6
-0
lms/templates/main.html
+1
-1
lms/templates/main_django.html
+14
-3
No files found.
common/djangoapps/edxmako/shortcuts.py
View file @
8eeb091d
...
@@ -77,6 +77,32 @@ def marketing_link_context_processor(request):
...
@@ -77,6 +77,32 @@ def marketing_link_context_processor(request):
)
)
def
header_footer_context_processor
(
request
):
"""
A django context processor to pass feature flags through to all Django
Templates that are related to the display of the header and footer in
the edX platform.
"""
# TODO: ECOM-136 Remove this processor with the corresponding header and footer feature flags.
return
dict
(
[
(
"ENABLE_NEW_EDX_HEADER"
,
settings
.
FEATURES
.
get
(
"ENABLE_NEW_EDX_HEADER"
,
False
)),
(
"ENABLE_NEW_EDX_FOOTER"
,
settings
.
FEATURES
.
get
(
"ENABLE_NEW_EDX_FOOTER"
,
False
))
]
)
def
open_source_footer_context_processor
(
request
):
"""
Checks the site name to determine whether to use the edX.org footer or the Open Source Footer.
"""
return
dict
(
[
(
"IS_EDX_DOMAIN"
,
settings
.
FEATURES
.
get
(
'IS_EDX_DOMAIN'
,
False
))
]
)
def
render_to_string
(
template_name
,
dictionary
,
context
=
None
,
namespace
=
'main'
):
def
render_to_string
(
template_name
,
dictionary
,
context
=
None
,
namespace
=
'main'
):
# see if there is an override template defined in the microsite
# see if there is an override template defined in the microsite
...
...
common/djangoapps/edxmako/tests.py
View file @
8eeb091d
from
mock
import
patch
,
Mock
from
mock
import
patch
,
Mock
import
unittest
import
unittest
import
ddt
from
django.conf
import
settings
from
django.conf
import
settings
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
...
@@ -10,11 +11,16 @@ from django.test.client import RequestFactory
...
@@ -10,11 +11,16 @@ from django.test.client import RequestFactory
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
import
edxmako.middleware
import
edxmako.middleware
from
edxmako
import
add_lookup
,
LOOKUP
from
edxmako
import
add_lookup
,
LOOKUP
from
edxmako.shortcuts
import
marketing_link
,
render_to_string
from
edxmako.shortcuts
import
(
marketing_link
,
render_to_string
,
header_footer_context_processor
,
open_source_footer_context_processor
)
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
util.testing
import
UrlResetMixin
from
util.testing
import
UrlResetMixin
@ddt.ddt
class
ShortcutsTests
(
UrlResetMixin
,
TestCase
):
class
ShortcutsTests
(
UrlResetMixin
,
TestCase
):
"""
"""
Test the edxmako shortcuts file
Test the edxmako shortcuts file
...
@@ -34,6 +40,26 @@ class ShortcutsTests(UrlResetMixin, TestCase):
...
@@ -34,6 +40,26 @@ class ShortcutsTests(UrlResetMixin, TestCase):
link
=
marketing_link
(
'ABOUT'
)
link
=
marketing_link
(
'ABOUT'
)
self
.
assertEquals
(
link
,
expected_link
)
self
.
assertEquals
(
link
,
expected_link
)
@ddt.data
((
True
,
True
),
(
False
,
False
),
(
False
,
True
),
(
True
,
False
))
@ddt.unpack
def
test_header_and_footer
(
self
,
header_setting
,
footer_setting
):
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_NEW_EDX_HEADER'
:
header_setting
,
'ENABLE_NEW_EDX_FOOTER'
:
footer_setting
,
}):
result
=
header_footer_context_processor
({})
self
.
assertEquals
(
footer_setting
,
result
.
get
(
'ENABLE_NEW_EDX_FOOTER'
))
self
.
assertEquals
(
header_setting
,
result
.
get
(
'ENABLE_NEW_EDX_HEADER'
))
@ddt.data
((
True
,
None
),
(
False
,
None
))
@ddt.unpack
def
test_edx_footer
(
self
,
expected_result
,
_
):
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'IS_EDX_DOMAIN'
:
expected_result
}):
result
=
open_source_footer_context_processor
({})
self
.
assertEquals
(
expected_result
,
result
.
get
(
'IS_EDX_DOMAIN'
))
class
AddLookupTests
(
TestCase
):
class
AddLookupTests
(
TestCase
):
"""
"""
...
...
lms/djangoapps/courseware/tests/test_footer.py
View file @
8eeb091d
...
@@ -3,35 +3,35 @@ Tests related to the basic footer-switching based off SITE_NAME to ensure
...
@@ -3,35 +3,35 @@ Tests related to the basic footer-switching based off SITE_NAME to ensure
edx.org uses an edx footer but other instances use an Open edX footer.
edx.org uses an edx footer but other instances use an Open edX footer.
"""
"""
from
mock
import
patch
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
class
TestFooter
(
TestCase
):
class
TestFooter
(
TestCase
):
@override_settings
(
SITE_NAME
=
"edx.org"
)
def
test_edx_footer
(
self
):
def
test_edx_footer
(
self
):
"""
"""
Verify that the homepage, when accessed at edx.org, has the edX footer
Verify that the homepage, when accessed at edx.org, has the edX footer
"""
"""
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
"IS_EDX_DOMAIN"
:
True
}):
resp
=
self
.
client
.
get
(
'/'
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
resp
=
self
.
client
.
get
(
'/'
)
# assert that footer template has been properly overridden on homepage
self
.
assertEqual
(
resp
.
status_code
,
200
)
# test the top-level element class; which is less likely to change than copy.
self
.
assertContains
(
resp
,
'edx-footer'
)
# assert that footer template has been properly overridden on homepage
# test the top-level element class; which is less likely to change than copy.
self
.
assertContains
(
resp
,
'edx-footer'
)
@override_settings
(
SITE_NAME
=
"example.com"
)
def
test_openedx_footer
(
self
):
def
test_openedx_footer
(
self
):
"""
"""
Verify that the homepage, when accessed at something other than
Verify that the homepage, when accessed at something other than
edx.org, has the Open edX footer
edx.org, has the Open edX footer
"""
"""
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
"IS_EDX_DOMAIN"
:
False
}):
resp
=
self
.
client
.
get
(
'/'
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
resp
=
self
.
client
.
get
(
'/'
)
# assert that footer template has been properly overridden on homepage
self
.
assertEqual
(
resp
.
status_code
,
200
)
# test the top-level element class; which is less likely to change than copy.
self
.
assertContains
(
resp
,
'wrapper-footer'
)
# assert that footer template has been properly overridden on homepage
# test the top-level element class; which is less likely to change than copy.
self
.
assertContains
(
resp
,
'wrapper-footer'
)
lms/envs/common.py
View file @
8eeb091d
...
@@ -367,6 +367,12 @@ TEMPLATE_CONTEXT_PROCESSORS = (
...
@@ -367,6 +367,12 @@ TEMPLATE_CONTEXT_PROCESSORS = (
# Hack to get required link URLs to password reset templates
# Hack to get required link URLs to password reset templates
'edxmako.shortcuts.marketing_link_context_processor'
,
'edxmako.shortcuts.marketing_link_context_processor'
,
# Allows the open edX footer to be leveraged in Django Templates.
'edxmako.shortcuts.open_source_footer_context_processor'
,
# TODO: Used for header and footer feature flags. Remove as part of ECOM-136
'edxmako.shortcuts.header_footer_context_processor'
,
# Shoppingcart processor (detects if request.user has a cart)
# Shoppingcart processor (detects if request.user has a cart)
'shoppingcart.context_processor.user_has_cart_context_processor'
,
'shoppingcart.context_processor.user_has_cart_context_processor'
,
)
)
...
...
lms/templates/main.html
View file @
8eeb091d
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
google_analytics_file =
microsite.get_template_path('google_analytics.html')
google_analytics_file =
microsite.get_template_path('google_analytics.html')
if
getattr
(
settings
,
'
SITE_NAME
',
'').
endswith
('
edx
.
org
')
and
not
is_microsite
()
:
if
settings
.
FEATURES
['
IS_EDX_DOMAIN
']
and
not
is_microsite
()
:
if
settings
.
FEATURES
.
get
('
ENABLE_NEW_EDX_FOOTER
',
False
)
:
if
settings
.
FEATURES
.
get
('
ENABLE_NEW_EDX_FOOTER
',
False
)
:
footer_file =
microsite.get_template_path('edx_footer.html')
footer_file =
microsite.get_template_path('edx_footer.html')
else:
else:
...
...
lms/templates/main_django.html
View file @
8eeb091d
...
@@ -31,13 +31,24 @@
...
@@ -31,13 +31,24 @@
<body
class=
"{% block bodyclass %}{% endblock %} lang_{{LANGUAGE_CODE}}"
>
<body
class=
"{% block bodyclass %}{% endblock %} lang_{{LANGUAGE_CODE}}"
>
<a
class=
"nav-skip"
href=
"{% block nav_skip %}#content{% endblock %}"
>
{% trans "Skip to this view's content" %}
</a>
<a
class=
"nav-skip"
href=
"{% block nav_skip %}#content{% endblock %}"
>
{% trans "Skip to this view's content" %}
</a>
{% include "navigation.html" %}
{% if ENABLE_NEW_EDX_HEADER %}
{% include "navigation.html" %}
{% else %}
{% include "original_navigation.html" %}
{% endif %}
<div
class=
"content-wrapper"
id=
"content"
>
<div
class=
"content-wrapper"
id=
"content"
>
{% block body %}{% endblock %}
{% block body %}{% endblock %}
{% block bodyextra %}{% endblock %}
{% block bodyextra %}{% endblock %}
</div>
</div>
{% if IS_EDX_DOMAIN %}
{% include "edx_footer.html" %}
{% if ENABLE_NEW_EDX_FOOTER %}
{% include "edx_footer.html" %}
{% else %}
{% include "original_edx_footer.html" %}
{% endif %}
{% else %}
{% include "footer.html" %}
{% endif %}
{% compressed_js 'application' %}
{% compressed_js 'application' %}
{% compressed_js 'module-js' %}
{% compressed_js 'module-js' %}
...
...
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