pass language to mako template
This commit is contained in:
@@ -79,7 +79,7 @@ def assets_handler(request, course_key_string=None, asset_key_string=None):
|
||||
return _update_asset(request, course_key, asset_key)
|
||||
|
||||
elif request.method == 'GET': # assume html
|
||||
return _asset_index(course_key)
|
||||
return _asset_index(request, course_key)
|
||||
|
||||
return HttpResponseNotFound()
|
||||
|
||||
@@ -92,7 +92,7 @@ def _request_response_format_is_json(request, response_format):
|
||||
return response_format == 'json' or 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json')
|
||||
|
||||
|
||||
def _asset_index(course_key):
|
||||
def _asset_index(request, course_key):
|
||||
'''
|
||||
Display an editable asset library.
|
||||
|
||||
@@ -101,6 +101,7 @@ def _asset_index(course_key):
|
||||
course_module = modulestore().get_course(course_key)
|
||||
|
||||
return render_to_response('asset_index.html', {
|
||||
'language_code': request.LANGUAGE_CODE,
|
||||
'waffle_flag_enabled': NewAssetsPageFlag.feature_enabled(course_key),
|
||||
'context_course': course_module,
|
||||
'max_file_size_in_mbs': settings.MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB,
|
||||
|
||||
@@ -75,9 +75,11 @@ def howitworks(request):
|
||||
|
||||
|
||||
@waffle_switch('{}.{}'.format(waffle.WAFFLE_NAMESPACE, waffle.ENABLE_ACCESSIBILITY_POLICY_PAGE))
|
||||
def accessibility(_request):
|
||||
def accessibility(request):
|
||||
"""
|
||||
Display the accessibility accommodation form.
|
||||
"""
|
||||
|
||||
return render_to_response('accessibility.html', {})
|
||||
return render_to_response('accessibility.html', {
|
||||
'language_code': request.LANGUAGE_CODE
|
||||
})
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
<div class="content">
|
||||
<div class="content-primary">
|
||||
<div id="root"></div>
|
||||
<%static:studiofrontend page="AccessibilityPage" lang="en">
|
||||
{}
|
||||
<%static:studiofrontend page="AccessibilityPage">
|
||||
{
|
||||
"lang": "${language_code | n, js_escaped_string}",
|
||||
}
|
||||
</%static:studiofrontend>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,8 +58,9 @@
|
||||
<div class="content">
|
||||
<%static:optional_include_mako file="asset_index_content_header.html" />
|
||||
% if waffle_flag_enabled:
|
||||
<%static:studiofrontend page="AssetsPage" lang="en">
|
||||
<%static:studiofrontend page="AssetsPage">
|
||||
{
|
||||
"lang": "${language_code | n, js_escaped_string}",
|
||||
"course": {
|
||||
"id": "${context_course.id | n, js_escaped_string}",
|
||||
"name": "${context_course.display_name_with_default | n, js_escaped_string}",
|
||||
|
||||
@@ -89,7 +89,7 @@ engine = Engine(dirs=settings.DEFAULT_TEMPLATE_ENGINE['DIRS'])
|
||||
source, template_path = Loader(engine).load_template_source(path)
|
||||
%>${source | n, decode.utf8}</%def>
|
||||
|
||||
<%def name="studiofrontend(page, lang='en')">
|
||||
<%def name="studiofrontend(page)">
|
||||
<%doc>
|
||||
Loads a studio-frontend page, with the necessary context. Context is expected
|
||||
as a dictionary in the body of this tag.
|
||||
@@ -101,8 +101,6 @@ source, template_path = Loader(engine).load_template_source(path)
|
||||
</%doc>
|
||||
<%
|
||||
body = capture(caller.body)
|
||||
body_dict = json.loads(body)
|
||||
body_dict['lang'] = lang
|
||||
%>
|
||||
<script type="text/javascript" id='courseContext'>
|
||||
var studioContext = ${ body | n, decode.utf8};
|
||||
|
||||
@@ -757,7 +757,7 @@ class TestMakoTemplateLinter(TestLinter):
|
||||
${x | h}
|
||||
</%static:require_module>
|
||||
${x | h}
|
||||
<%static:studiofrontend page="${x}" lang="en">
|
||||
<%static:studiofrontend page="${x}">
|
||||
${x | h}
|
||||
</%static:studiofrontend>
|
||||
${x | h}
|
||||
|
||||
Reference in New Issue
Block a user