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
37844fd9
Unverified
Commit
37844fd9
authored
Nov 29, 2017
by
Uman Shahzad
Committed by
GitHub
Nov 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15947 from open-craft/allow-theme-template-block-override
Allow theme template block override
parents
167b2830
96e704e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
common/djangoapps/edxmako/paths.py
+5
-0
common/test/test-theme/lms/templates/dashboard.html
+4
-0
openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py
+24
-0
No files found.
common/djangoapps/edxmako/paths.py
View file @
37844fd9
...
...
@@ -70,6 +70,11 @@ class DynamicTemplateLookup(TemplateLookup):
try
:
# Try to find themed template, i.e. see if current theme overrides the template
template
=
super
(
DynamicTemplateLookup
,
self
)
.
get_template
(
get_template_path_with_theme
(
uri
))
# For an overriding template, the uri is the path to the same template, so the lookup always
# finds the same overriding template. If that's the case, route to exception so that the
# uri can be stripped of the path and the parent template can be found.
if
template
==
super
(
DynamicTemplateLookup
,
self
)
.
get_template
(
uri
):
raise
TopLevelLookupException
()
except
TopLevelLookupException
:
# strip off the prefix path to theme and look in default template dirs
template
=
super
(
DynamicTemplateLookup
,
self
)
.
get_template
(
strip_site_theme_templates_path
(
uri
))
...
...
common/test/test-theme/lms/templates/dashboard.html
0 → 100644
View file @
37844fd9
<
%
inherit
file=
"dashboard.html"
/>
<
%
block
name=
"pagetitle"
>
Overridden Title!
</
%
block>
${parent.body()}
<
%
block
name=
"bodyextra"
>
Overriden Body Extra!
</
%
block>
openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py
View file @
37844fd9
...
...
@@ -64,6 +64,30 @@ class TestComprehensiveThemeLMS(TestCase):
result
=
staticfiles
.
finders
.
find
(
'test-theme/images/logo.png'
)
self
.
assertEqual
(
result
,
settings
.
TEST_THEME
/
'lms/static/images/logo.png'
)
@with_comprehensive_theme
(
"test-theme"
)
def
test_override_block_in_parent
(
self
):
"""
Test that theme title is used instead of parent title.
"""
self
.
_login
()
dashboard_url
=
reverse
(
'dashboard'
)
resp
=
self
.
client
.
get
(
dashboard_url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# This string comes from the 'pagetitle' block of the overriding theme.
self
.
assertContains
(
resp
,
"Overridden Title!"
)
@with_comprehensive_theme
(
"test-theme"
)
def
test_override_block_in_grandparent
(
self
):
"""
Test that theme title is used instead of parent's parent's title.
"""
self
.
_login
()
dashboard_url
=
reverse
(
'dashboard'
)
resp
=
self
.
client
.
get
(
dashboard_url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# This string comes from the 'bodyextra' block of the overriding theme.
self
.
assertContains
(
resp
,
"Overriden Body Extra!"
)
@skip_unless_cms
class
TestComprehensiveThemeCMS
(
TestCase
):
...
...
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