Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-utils
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
xblock-utils
Commits
8ba72515
Commit
8ba72515
authored
May 09, 2018
by
Jillian Vogel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensures that default template tags are loaded for Django 1.11
parent
436576de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
2 deletions
+23
-2
setup.py
+1
-1
tests/unit/data/l10n_django_template.txt
+3
-0
tests/unit/test_resources.py
+14
-0
xblockutils/resources.py
+5
-1
No files found.
setup.py
View file @
8ba72515
...
@@ -35,7 +35,7 @@ def package_data(pkg, root_list):
...
@@ -35,7 +35,7 @@ def package_data(pkg, root_list):
setup
(
setup
(
name
=
'xblock-utils'
,
name
=
'xblock-utils'
,
version
=
'1.1.
0
'
,
version
=
'1.1.
1
'
,
description
=
'Various utilities for XBlocks'
,
description
=
'Various utilities for XBlocks'
,
packages
=
[
packages
=
[
'xblockutils'
,
'xblockutils'
,
...
...
tests/unit/data/l10n_django_template.txt
0 → 100644
View file @
8ba72515
{% load l10n %}
{{ 1000|localize }}
{{ 1000|unlocalize }}
tests/unit/test_resources.py
View file @
8ba72515
...
@@ -90,6 +90,12 @@ mUlTi_LiNe TrAnSlAtIoN: This is a fine name
...
@@ -90,6 +90,12 @@ mUlTi_LiNe TrAnSlAtIoN: This is a fine name
"""
"""
expected_localized_template
=
u"""
\
1000
1000
"""
example_id
=
"example-unique-id"
example_id
=
"example-unique-id"
expected_filled_js_template
=
u"""
\
expected_filled_js_template
=
u"""
\
...
@@ -167,6 +173,14 @@ class TestResourceLoader(unittest.TestCase):
...
@@ -167,6 +173,14 @@ class TestResourceLoader(unittest.TestCase):
s
=
loader
.
render_django_template
(
"data/trans_django_template.txt"
,
example_context
)
s
=
loader
.
render_django_template
(
"data/trans_django_template.txt"
,
example_context
)
self
.
assertEquals
(
s
,
expected_not_translated_template
)
self
.
assertEquals
(
s
,
expected_not_translated_template
)
def
test_render_django_template_localized
(
self
):
# Test that default template tags like l10n are loaded
loader
=
ResourceLoader
(
__name__
)
s
=
loader
.
render_django_template
(
"data/l10n_django_template.txt"
,
context
=
example_context
,
i18n_service
=
MockI18nService
())
self
.
assertEquals
(
s
,
expected_localized_template
)
def
test_render_mako_template
(
self
):
def
test_render_mako_template
(
self
):
loader
=
ResourceLoader
(
__name__
)
loader
=
ResourceLoader
(
__name__
)
s
=
loader
.
render_mako_template
(
"data/simple_mako_template.txt"
,
example_context
)
s
=
loader
.
render_mako_template
(
"data/simple_mako_template.txt"
,
example_context
)
...
...
xblockutils/resources.py
View file @
8ba72515
...
@@ -68,7 +68,11 @@ class ResourceLoader(object):
...
@@ -68,7 +68,11 @@ class ResourceLoader(object):
engine
=
Engine
()
engine
=
Engine
()
else
:
else
:
# Django>1.8 Engine can load the extra templatetag libraries itself
# Django>1.8 Engine can load the extra templatetag libraries itself
engine
=
Engine
(
libraries
=
libraries
)
# but we have to override the default installed libraries.
from
django.template.backends.django
import
get_installed_libraries
installed_libraries
=
get_installed_libraries
()
installed_libraries
.
update
(
libraries
)
engine
=
Engine
(
libraries
=
installed_libraries
)
template_str
=
self
.
load_unicode
(
template_path
)
template_str
=
self
.
load_unicode
(
template_path
)
template
=
Template
(
template_str
,
engine
=
engine
)
template
=
Template
(
template_str
,
engine
=
engine
)
...
...
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