Adding support for microsite template_paths on django templates
Stripping the leading / for the django_templates finder Enabling the microsite configurations before running django.setup() Adding only the templates directory before startup Adding the missing overrides file at the django templates main Using the comp_theming way of overriding css Adding test for the microsite_template_path filter
This commit is contained in:
@@ -63,3 +63,14 @@ def microsite_css_overrides_file():
|
||||
return "<link href='{}' rel='stylesheet' type='text/css'>".format(static(file_path))
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
@register.filter
|
||||
def microsite_template_path(template_name):
|
||||
"""
|
||||
Django template filter to apply template overriding to microsites.
|
||||
The django_templates loader does not support the leading slash, therefore
|
||||
it is stripped before returning.
|
||||
"""
|
||||
template_name = microsite.get_template_path(template_name)
|
||||
return template_name[1:] if template_name[0] == '/' else template_name
|
||||
|
||||
@@ -32,3 +32,10 @@ class MicroSiteTests(TestCase):
|
||||
expected = u'my | less specific | Page | edX'
|
||||
title = microsite.page_title_breadcrumbs_tag(None, *crumbs)
|
||||
self.assertEqual(expected, title)
|
||||
|
||||
def test_microsite_template_path(self):
|
||||
"""
|
||||
When an unexistent path is passed to the filter, it should return the same path
|
||||
"""
|
||||
path = microsite.microsite_template_path('footer.html')
|
||||
self.assertEqual("footer.html", path)
|
||||
|
||||
Reference in New Issue
Block a user