Move the context course and sock into require_page compatible forms

This commit is contained in:
Calen Pennington
2018-01-24 16:31:20 -05:00
committed by Ari Rizzitano
parent 6998b311fe
commit 970bc6a50d
8 changed files with 112 additions and 67 deletions

View File

@@ -121,39 +121,39 @@ from openedx.core.djangolib.markup import HTML
<%block name="modal_placeholder"></%block>
<%block name="jsextra"></%block>
<%block name="page_bundle">
<script type="text/javascript">
if (typeof window.pageFactoryArguments == "undefined") {
% if context_course:
<script type="text/javascript">
if (typeof window.pageFactoryArguments == "undefined") {
window.pageFactoryArguments = {};
}
% if context_course:
window.pageFactoryArguments['ContextCourse'] = {
id: "${context_course.id | n, js_escaped_string}",
name: "${context_course.display_name_with_default | n, js_escaped_string}",
url_name: "${context_course.location.block_id | n, js_escaped_string}",
org: "${context_course.location.org | n, js_escaped_string}",
num: "${context_course.location.course | n, js_escaped_string}",
display_course_number: "${context_course.display_coursenumber | n, js_escaped_string}",
revision: "${context_course.location.branch | n, js_escaped_string}",
self_paced: ${ context_course.self_paced | n, dump_js_escaped_json }
}
% endif
}
require(['js/factories/base'], function () {
require(['js/models/course'], function(Course) {
% if context_course:
window.course = new Course(
window.pageFactoryArguments['ContextCourse']
);
% endif
% if user.is_authenticated():
require(['js/sock']);
% endif
<%block name='requirejs'></%block>
});
});
</script>
window.pageFactoryArguments['ContextCourse'] = {
id: "${context_course.id | n, js_escaped_string}",
name: "${context_course.display_name_with_default | n, js_escaped_string}",
url_name: "${context_course.location.block_id | n, js_escaped_string}",
org: "${context_course.location.org | n, js_escaped_string}",
num: "${context_course.location.course | n, js_escaped_string}",
display_course_number: "${context_course.display_coursenumber | n, js_escaped_string}",
revision: "${context_course.location.branch | n, js_escaped_string}",
self_paced: ${ context_course.self_paced | n, dump_js_escaped_json }
}
</script>
% endif
% if user.is_authenticated():
<%static:invoke_page_bundle page_name='js/sock'/>
% endif
<%block name='page_bundle'>
<script type="text/javascript">
require(['js/factories/base'], function () {
require(['js/models/course'], function(Course) {
% if context_course:
window.course = new Course(window.pageFactoryArguments['ContextCourse']);
% endif
<%block name='requirejs'></%block>
});
});
</script>
</%block>
<%include file="widgets/segment-io-footer.html" />
<div class="modal-cover"></div>