def render_renderReact(context, component, id, props={}): __M_caller = context.caller_stack._push_frame() try: __M_writer = context.writer() __M_writer(u'\n ') __M_writer(u'\n\n ') __M_writer( filters.html_escape( filters.decode.utf8(HTML(render_bundle(component))))) __M_writer(u'\n ') __M_writer( filters.html_escape( filters.decode.utf8(HTML(render_bundle('ReactRenderer'))))) __M_writer(u'\n\n <div id="') __M_writer(filters.html_escape(filters.decode.utf8(id))) __M_writer( u'"></div>\n <script type="text/javascript">\n var c;\n try { c = ' ) __M_writer(filters.decode.utf8(component)) __M_writer( u"; } catch (e) { c = null; }\n new ReactRenderer({\n component: c,\n selector: '#" ) __M_writer(filters.decode.utf8(id)) __M_writer(u"',\n componentName: '") __M_writer(js_escaped_string(component)) __M_writer(u"',\n props: ") __M_writer(dump_js_escaped_json(props)) __M_writer(u'\n });\n </script>\n') return '' finally: context.caller_stack._pop_frame()
def body(): data = context.get('data', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n var options = ') __M_writer(dump_js_escaped_json(data)) __M_writer(u';\n LearnerProfileFactory(options);\n') return ''
def _assert_third_party_auth_data(self, response, current_backend, current_provider, providers, expected_ec, add_user_details=False): """Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse("social:complete", kwargs={"backend": current_backend}) + "?" auth_info = { "currentProvider": current_provider, "providers": providers, "secondaryProviders": [], "finishAuthUrl": finish_auth_url, "errorMessage": None, "registerFormSubmitButtonText": "Create Account", "syncLearnerProfileData": False, "pipeline_user_details": {"email": "*****@*****.**"} if add_user_details else {} } if expected_ec is not None: # If we set an EnterpriseCustomer, third-party auth providers ought to be hidden. auth_info['providers'] = [] auth_info = dump_js_escaped_json(auth_info) expected_data = u'"third_party_auth": {auth_info}'.format( auth_info=auth_info ) self.assertContains(response, expected_data)
def inner(request, *args, **kwargs): if request.is_ajax(): content = dump_js_escaped_json({"error": message}) return HttpResponse(content, content_type="application/json", status=status) else: return func(request, *args, **kwargs)
def render_body(context, **pageargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) content = context.get('content', UNDEFINED) classes = context.get('classes', UNDEFINED) data_attributes = context.get('data_attributes', UNDEFINED) js_init_parameters = context.get('js_init_parameters', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n<div class="') __M_writer(filters.decode.utf8(' '.join(classes))) __M_writer(u'" ') __M_writer(filters.decode.utf8(data_attributes)) __M_writer(u'>\n') if js_init_parameters: __M_writer( u' <script type="json/xblock-args" class="xblock-json-init-args">\n ' ) __M_writer(dump_js_escaped_json(js_init_parameters)) __M_writer(u'\n </script>\n') __M_writer(u' ') __M_writer(filters.decode.utf8(content)) __M_writer(u'\n</div>\n') return '' finally: context.caller_stack._pop_frame()
def _assert_saml_auth_data_with_error( self, response, current_backend, current_provider, expected_error_message ): """ Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse('social:complete', kwargs={'backend': current_backend}) + '?' auth_info = { 'currentProvider': current_provider, 'providers': [], 'secondaryProviders': [], 'finishAuthUrl': finish_auth_url, 'errorMessage': expected_error_message, 'registerFormSubmitButtonText': 'Create Account', 'syncLearnerProfileData': False, 'pipeline_user_details': {'response': {'idp_name': 'testshib'}} } auth_info = dump_js_escaped_json(auth_info) expected_data = u'"third_party_auth": {auth_info}'.format( auth_info=auth_info ) self.assertContains(response, expected_data)
def get(self, request, *args, **kwargs): """Returns organization list as json.""" # organizations = get_organizations() # org_names_list = [(org["short_name"]) for org in organizations] # EDUNEXT: Organizations list must not be visible for users, reason why an empty array is returned org_names_list = [] return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8')
def _assert_third_party_auth_data(self, response, current_backend, current_provider, providers, expected_ec, add_user_details=False): """Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse( "social:complete", kwargs={"backend": current_backend}) + "?" auth_info = { "currentProvider": current_provider, "providers": providers, "secondaryProviders": [], "finishAuthUrl": finish_auth_url, "errorMessage": None, "registerFormSubmitButtonText": "Create Account", "syncLearnerProfileData": False, "pipeline_user_details": { "email": "*****@*****.**" } if add_user_details else {} } if expected_ec is not None: # If we set an EnterpriseCustomer, third-party auth providers ought to be hidden. auth_info['providers'] = [] auth_info = dump_js_escaped_json(auth_info) expected_data = '"third_party_auth": {auth_info}'.format( auth_info=auth_info) self.assertContains(response, expected_data)
def inner(request, *args, **kwargs): if request.is_ajax(): content = dump_js_escaped_json({"error": message}) return HttpResponse(content, content_type="application/json", # lint-amnesty, pylint: disable=http-response-with-content-type-json status=status) else: return func(request, *args, **kwargs)
def _assert_third_party_auth_data(self, response, current_backend, current_provider, providers, expected_ec): """Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse( "social:complete", kwargs={"backend": current_backend}) + "?" auth_info = { "currentProvider": current_provider, "providers": providers, "secondaryProviders": [], "finishAuthUrl": finish_auth_url, "errorMessage": None, } if expected_ec is not None: # If we set an EnterpriseCustomer, third-party auth providers ought to be hidden. auth_info['providers'] = [] auth_info = dump_js_escaped_json(auth_info) expected_data = '"third_party_auth": {auth_info}'.format( auth_info=auth_info) self.assertContains(response, expected_data)
def _assert_saml_auth_data_with_error(self, response, current_backend, current_provider, expected_error_message): """ Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse( 'social:complete', kwargs={'backend': current_backend}) + '?' auth_info = { 'currentProvider': current_provider, 'providers': [], 'secondaryProviders': [], 'finishAuthUrl': finish_auth_url, 'errorMessage': expected_error_message, 'registerFormSubmitButtonText': 'Create Account', 'syncLearnerProfileData': False, 'pipeline_user_details': { 'response': { 'idp_name': 'testshib' } } } auth_info = dump_js_escaped_json(auth_info) expected_data = '"third_party_auth": {auth_info}'.format( auth_info=auth_info) self.assertContains(response, expected_data)
def get(self, request, *args, **kwargs): """Returns organization list as json.""" specialzations = specializations.objects.all() specz_names_list = [(specz["short_name"]) for specz in specialzations] return HttpResponse( dump_js_escaped_json(specz_names_list), content_type="application/json; charset=utf-8", )
def body(): __M_writer = context.writer() __M_writer( u"\n var banner = new MessageBannerView({urgency: 'low', type: 'warning', hideCloseBtn: false, isRecoveryEmailMsg: true});\n $('#content').prepend(banner.$el);\n banner.showMessage(" ) __M_writer(dump_js_escaped_json(recovery_email_message)) __M_writer(u')\n ') return ''
def body(): __M_writer = context.writer() __M_writer( u"\n var banner = new MessageBannerView({urgency: 'low', type: 'warning'});\n $('#content').prepend(banner.$el);\n banner.showMessage(" ) __M_writer(dump_js_escaped_json(redirect_message)) __M_writer(u')\n ') return ''
def get(self, request, *args, **kwargs): """Returns organization list as json.""" organizations = get_organizations() # [COLARAZ_CUSTOM] # Restrict user from creating courses with non-authorized organizations org_names_list = filter_authorized_organizations_from_list( organizations, request.user.is_superuser) return HttpResponse( dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8')
def test_dump_js_escaped_json_escapes_unsafe_html(self): """ Test dump_js_escaped_json properly escapes &, <, and >. """ malicious_dict = {"</script><script>alert('hello, ');</script>": "</script><script>alert('&world!');</script>"} expected_escaped_json = ( r'''{"\u003c/script\u003e\u003cscript\u003ealert('hello, ');\u003c/script\u003e": ''' r'''"\u003c/script\u003e\u003cscript\u003ealert('\u0026world!');\u003c/script\u003e"}''' ) escaped_json = dump_js_escaped_json(malicious_dict) self.assertEquals(expected_escaped_json, escaped_json)
def body(): user_timezone = context.get('user_timezone', UNDEFINED) course_discovery_meanings = context.get('course_discovery_meanings', UNDEFINED) user_language = context.get('user_language', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n DiscoveryFactory(\n ') __M_writer(dump_js_escaped_json(course_discovery_meanings )) __M_writer(u',\n getParameterByName(\'search_query\'),\n "') __M_writer(filters.decode.utf8(user_language)) __M_writer(u'",\n "') __M_writer(filters.decode.utf8(user_timezone)) __M_writer(u'"\n );\n ') return ''
def _assert_third_party_auth_data(self, response, current_backend, current_provider, providers): """Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse("social:complete", kwargs={"backend": current_backend}) + "?" auth_info = { "currentProvider": current_provider, "providers": providers, "secondaryProviders": [], "finishAuthUrl": finish_auth_url, "errorMessage": None, } auth_info = dump_js_escaped_json(auth_info) expected_data = '"third_party_auth": {auth_info}'.format(auth_info=auth_info) self.assertContains(response, expected_data)
def test_dump_js_escaped_json_with_custom_encoder_escapes_unsafe_html(self): """ Test dump_js_escaped_json first encodes with custom JSNOEncoder before escaping &, <, and > The test encoder class should first perform the replacement of "<script>" with "sample-encoder-was-here", and then should escape the remaining &, <, and >. """ malicious_dict = { "</script><script>alert('hello, ');</script>": self.NoDefaultEncoding("</script><script>alert('&world!');</script>") } expected_custom_escaped_json = ( r'''{"\u003c/script\u003e\u003cscript\u003ealert('hello, ');\u003c/script\u003e": ''' r'''"\u003c/script\u003esample-encoder-was-herealert('\u0026world!');\u003c/script\u003e"}''' ) escaped_json = dump_js_escaped_json(malicious_dict, cls=self.SampleJSONEncoder) self.assertEquals(expected_custom_escaped_json, escaped_json)
def _assert_third_party_auth_data(self, response, current_backend, current_provider, providers): """Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse("social:complete", kwargs={"backend": current_backend}) + "?" auth_info = { "currentProvider": current_provider, "providers": providers, "secondaryProviders": [], "finishAuthUrl": finish_auth_url, "errorMessage": None, } auth_info = dump_js_escaped_json(auth_info) expected_data = '"third_party_auth": {auth_info}'.format( auth_info=auth_info ) self.assertContains(response, expected_data)
def _get_entrance_exam(request, course_key): # pylint: disable=W0613 """ Internal workflow operation to retrieve an entrance exam """ course = modulestore().get_course(course_key) if course is None: return HttpResponse(status=400) if not course.entrance_exam_id: return HttpResponse(status=404) try: exam_key = UsageKey.from_string(course.entrance_exam_id) except InvalidKeyError: return HttpResponse(status=404) try: exam_descriptor = modulestore().get_item(exam_key) return HttpResponse( dump_js_escaped_json({'locator': unicode(exam_descriptor.location)}), status=200, content_type='application/json') except ItemNotFoundError: return HttpResponse(status=404)
def _get_entrance_exam(request, course_key): # pylint: disable=W0613 """ Internal workflow operation to retrieve an entrance exam """ course = modulestore().get_course(course_key) if course is None: return HttpResponse(status=400) if not course.entrance_exam_id: return HttpResponse(status=404) try: exam_key = UsageKey.from_string(course.entrance_exam_id) except InvalidKeyError: return HttpResponse(status=404) try: exam_descriptor = modulestore().get_item(exam_key) return HttpResponse( dump_js_escaped_json({'locator': six.text_type(exam_descriptor.location)}), status=200, content_type='application/json') except ItemNotFoundError: return HttpResponse(status=404)
def _assert_third_party_auth_data(self, response, current_backend, current_provider, providers, expected_ec): """Verify that third party auth info is rendered correctly in a DOM data attribute. """ finish_auth_url = None if current_backend: finish_auth_url = reverse("social:complete", kwargs={"backend": current_backend}) + "?" auth_info = { "currentProvider": current_provider, "providers": providers, "secondaryProviders": [], "finishAuthUrl": finish_auth_url, "errorMessage": None, } if expected_ec is not None: # If we set an EnterpriseCustomer, third-party auth providers ought to be hidden. auth_info['providers'] = [] auth_info = dump_js_escaped_json(auth_info) expected_data = '"third_party_auth": {auth_info}'.format( auth_info=auth_info ) self.assertContains(response, expected_data)
def get(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument """Returns organization list as json.""" organizations = get_organizations() org_names_list = [(org["short_name"]) for org in organizations] return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8') # lint-amnesty, pylint: disable=http-response-with-content-type-json
def render_body(context, **pageargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) basestring = context.get('basestring', UNDEFINED) course = context.get('course', UNDEFINED) user = context.get('user', UNDEFINED) unicode = context.get('unicode', UNDEFINED) course_id = context.get('course_id', UNDEFINED) isinstance = context.get('isinstance', UNDEFINED) hasattr = context.get('hasattr', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') __M_writer(u'\n') user_metadata = { key: context.get(key) for key in ( 'username', 'user_id', 'course_id', 'enrollment_mode', 'upgrade_link', 'upgrade_price', 'pacing_type', 'has_staff_access', 'forum_roles', 'partition_groups', # TODO: clean up as part of REVO-28 (START) 'has_non_audit_enrollments', # TODO: clean up as part of REVO-28 (END) ) } if user: user_metadata['username'] = user.username user_metadata['user_id'] = user.id if hasattr(user, 'email'): user_metadata['email'] = user.email for datekey in ('schedule_start', 'enrollment_time', 'course_start', 'course_end', 'upgrade_deadline'): user_metadata[datekey] = (context.get(datekey).isoformat() if context.get(datekey) else None) course_key = context.get('course_key') if course and not course_key: course_key = course.id if course_key: if isinstance(course_key, CourseKey): user_metadata['course_key_fields'] = { 'org': course_key.org, 'course': course_key.course, 'run': course_key.run, } if not course_id: user_metadata['course_id'] = unicode(course_key) elif isinstance(course_key, basestring): user_metadata['course_id'] = course_key __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([ (__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['datekey', 'user_metadata', 'key', 'course_key'] if __M_key in __M_locals_builtin_stored ])) __M_writer( u'\n<script type="application/json" id="user-metadata">\n ') __M_writer(dump_js_escaped_json(user_metadata)) __M_writer(u'\n</script>\n') return '' finally: context.caller_stack._pop_frame()
def render_body(context, grade_summary, grade_cutoffs, graph_div_id, show_grade_breakdown=True, show_grade_cutoffs=True, **kwargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin( show_grade_breakdown=show_grade_breakdown, graph_div_id=graph_div_id, grade_summary=grade_summary, show_grade_cutoffs=show_grade_cutoffs, grade_cutoffs=grade_cutoffs, kwargs=kwargs) sorted = context.get('sorted', UNDEFINED) len = context.get('len', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') __M_writer( u'\n\n$(function () {\n function showTooltip(x, y, contents) {\n $("#tooltip").remove();\n var $tooltip_div = $(\'<div id="tooltip"></div>\').css({\n position: \'absolute\',\n display: \'none\',\n top: y + 5,\n left: x + 15,\n border: \'1px solid #000\',\n padding: \'4px 6px\',\n color: \'#fff\',\n \'background-color\': \'#222\',\n opacity: 0.90\n });\n\n edx.HtmlUtils.setHtml(\n $tooltip_div,\n edx.HtmlUtils.HTML(contents)\n );\n \n edx.HtmlUtils.append(\n $(\'body\'),\n edx.HtmlUtils.HTML($tooltip_div)\n );\n \n $(\'#tooltip\').fadeIn(200);\n }\n /* -------------------------------- Grade detail bars -------------------------------- */\n \n ' ) colors = ["#b72121", "#600101", "#666666", "#333333"] categories = {} tickIndex = 1 sectionSpacer = 0.25 sectionIndex = 0 ticks = [] #These are the indices and x-axis labels for the data bottomTicks = [] #Labels on the bottom detail_tooltips = { } #This an dictionary mapping from 'section' -> array of detail_tooltips droppedScores = [ ] #These are the datapoints to indicate assignments which are not factored into the total score dropped_score_tooltips = [] for section in grade_summary['section_breakdown']: if section.get('prominent', False): tickIndex += sectionSpacer if section['category'] not in categories: colorIndex = len(categories) % len(colors) categories[section['category']] = { 'label': section['category'], 'data': [], 'color': colors[colorIndex] } categoryData = categories[section['category']] ## Because this is Python (Mako) embedded in JavaScript, our xss linting script is ## thoroughly confused. We should rewrite this file to remove Python/Mako. ## xss-lint: disable=javascript-jquery-append categoryData['data'].append([tickIndex, section['percent']]) ## Note that some courses had stored images in the Abbreviation. We are no longer ## allowing the display of such images, and remove any previously stored HTML ## to prevent ugly HTML from being shown to learners. ## xss-lint: disable=javascript-jquery-append ticks.append([ tickIndex, bleach.clean(section['label'], tags=[], strip=True) ]) if section['category'] in detail_tooltips: ## xss-lint: disable=javascript-jquery-append detail_tooltips[section['category']].append(section['detail']) else: detail_tooltips[section['category']] = [ section['detail'], ] if 'mark' in section: ## xss-lint: disable=javascript-jquery-append droppedScores.append([tickIndex, 0.05]) ## xss-lint: disable=javascript-jquery-append dropped_score_tooltips.append(section['mark']['detail']) tickIndex += 1 if section.get('prominent', False): tickIndex += sectionSpacer ## ----------------------------- Grade overview bar ------------------------- ## tickIndex += sectionSpacer series = categories.values() overviewBarX = tickIndex extraColorIndex = len( categories ) #Keeping track of the next color to use for categories not in categories[] if show_grade_breakdown: for section in grade_summary['grade_breakdown'].itervalues(): if section['percent'] > 0: if section['category'] in categories: color = categories[section['category']]['color'] else: color = colors[extraColorIndex % len(colors)] extraColorIndex += 1 ## xss-lint: disable=javascript-jquery-append series.append({ 'label': section['category'] + "-grade_breakdown", 'data': [[overviewBarX, section['percent']]], 'color': color }) detail_tooltips[section['category'] + "-grade_breakdown"] = [section['detail']] ticks += [[overviewBarX, "Total"]] tickIndex += 1 + sectionSpacer totalScore = grade_summary['percent'] detail_tooltips['Dropped Scores'] = dropped_score_tooltips ## ----------------------------- Grade cutoffs ------------------------- ## grade_cutoff_ticks = [[1, "100%"], [0, "0%"]] if show_grade_cutoffs: grade_cutoff_ticks = [[1, "100%"], [0, "0%"]] descending_grades = sorted(grade_cutoffs, key=lambda x: grade_cutoffs[x], reverse=True) for grade in descending_grades: percent = grade_cutoffs[grade] ## xss-lint: disable=javascript-jquery-append grade_cutoff_ticks.append( [percent, u"{0} {1:.0%}".format(grade, percent)]) else: grade_cutoff_ticks = [] __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([ (__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in [ 'colorIndex', 'color', 'series', 'extraColorIndex', 'grade_cutoff_ticks', 'colors', 'totalScore', 'sectionSpacer', 'dropped_score_tooltips', 'descending_grades', 'section', 'ticks', 'percent', 'detail_tooltips', 'grade', 'bottomTicks', 'tickIndex', 'categoryData', 'categories', 'sectionIndex', 'overviewBarX', 'droppedScores' ] if __M_key in __M_locals_builtin_stored ])) __M_writer(u'\n \n var series = ') __M_writer(dump_js_escaped_json(series)) __M_writer(u';\n var ticks = ') __M_writer(dump_js_escaped_json(ticks)) __M_writer(u';\n var bottomTicks = ') __M_writer(dump_js_escaped_json(bottomTicks)) __M_writer(u';\n var detail_tooltips = ') __M_writer(dump_js_escaped_json(detail_tooltips)) __M_writer(u';\n var droppedScores = ') __M_writer(dump_js_escaped_json(droppedScores)) __M_writer(u';\n var grade_cutoff_ticks = ') __M_writer(dump_js_escaped_json(grade_cutoff_ticks)) __M_writer( u'\n \n var yAxisTooltips={};\n\n /*\n series looks like:\n [\n {\n color: "#600101",\n label: "Homework",\n data: [[1, 0.06666666666666667], [2, 1], [3.25, .53]]\n },\n ...\n ]\n\n detail_tooltips looks like:\n {\n "Dropped Scores": [0: "The lowest 1...:],\n "Homework": [\n 0: "Homework 1 -- Homework -- Question Styles 7% (1/15)",\n 1: "Homework 2 -- Homework -- Get Social 100% (1/1)",\n 2: "Homework Average = 53%"\n ],\n ...\n }\n */\n\n // loop through the series and extract the matching tick and the series label\n for (var seriesIndex = 0; seriesIndex < series.length; seriesIndex++) {\n for (var dataIndex = 0; dataIndex < series[seriesIndex][\'data\'].length; dataIndex++) {\n var tickIndex = series[seriesIndex][\'data\'][dataIndex][0];\n // There may be more than one detail tooltip for a given tickIndex. If so,\n // push the new tooltip on the existing list.\n if (tickIndex in yAxisTooltips) {\n yAxisTooltips[tickIndex].push(detail_tooltips[series[seriesIndex][\'label\']][dataIndex]);\n } else {\n yAxisTooltips[tickIndex] = [detail_tooltips[series[seriesIndex][\'label\']][dataIndex]];\n }\n // If this item was a dropped score, add the tooltip message about that.\n for (var droppedIndex = 0; droppedIndex < droppedScores.length; droppedIndex++) {\n if (tickIndex === droppedScores[droppedIndex][0]) {\n yAxisTooltips[tickIndex].push(detail_tooltips["Dropped Scores"][droppedIndex]);\n }\n }\n }\n }\n\n // hide the vertical axis since they are audibly lacking context\n for (var i = 0; i < grade_cutoff_ticks.length; i++) {\n grade_cutoff_ticks[i][1] = edx.HtmlUtils.joinHtml(\n edx.HtmlUtils.HTML(\'<span aria-hidden="true">\'),\n grade_cutoff_ticks[i][1],\n edx.HtmlUtils.HTML(\'</span>\')\n ).text;\n }\n \n //Always be sure that one series has the xaxis set to 2, or the second xaxis labels won\'t show up\n series.push( {label: \'Dropped Scores\', data: droppedScores, points: {symbol: "cross", show: true, radius: 3}, bars: {show: false}, color: "#333"} );\n \n // Allow for arbitrary grade markers e.g. [\'A\', \'B\', \'C\'], [\'Pass\'], etc.\n var ascending_grades = grade_cutoff_ticks.map(function (el) { return el[0]; }); // Percentage point (in decimal) of each grade cutoff\n ascending_grades.sort();\n\n var colors = [\'#f3f3f3\', \'#e9e9e9\', \'#ddd\'];\n var markings = [];\n for(var i=1; i<ascending_grades.length-1; i++) // Skip the i=0 marking, which starts from 0%\n markings.push({yaxis: {from: ascending_grades[i], to: ascending_grades[i+1]}, color: colors[(i-1) % colors.length]});\n\n var options = {\n series: {\n stack: true,\n lines: {\n show: false,\n steps: false\n },\n bars: {\n show: true,\n barWidth: 0.8,\n align: \'center\',\n lineWidth: 0,\n fill: .8\n }\n },\n xaxis: {\n tickLength: 0,\n min: 0.0,\n max: ' ) __M_writer(dump_js_escaped_json(tickIndex - sectionSpacer)) __M_writer( u',\n ticks: function() {\n for (var i = 0; i < ticks.length; i++) {\n var tickLabel = edx.HtmlUtils.joinHtml(\n // The very last tick will be for the total, and it usually is composed of a number of different\n // grading types. To help clarify, do NOT make the label ("Total") aria-hidden in that case.\n edx.HtmlUtils.HTML(i < ticks.length - 1 ? \'<span aria-hidden="true">\' : \'<span>\'),\n ticks[i][1],\n edx.HtmlUtils.HTML(\'</span>\')\n );\n var elementTooltips = yAxisTooltips[ticks[i][0]];\n if (elementTooltips) {\n for (var tooltipIndex = 0; tooltipIndex < elementTooltips.length; tooltipIndex++) {\n tickLabel = edx.HtmlUtils.joinHtml(\n tickLabel,\n edx.HtmlUtils.HTML(\'<span class="sr">\'),\n elementTooltips[tooltipIndex],\n edx.HtmlUtils.HTML(\'<br></span>\')\n );\n }\n }\n ticks[i][1] = tickLabel;\n }\n return ticks;\n },\n labelAngle: 90\n },\n yaxis: {\n ticks: grade_cutoff_ticks,\n min: 0.0,\n max: 1.0,\n labelWidth: 100\n },\n grid: {\n hoverable: true,\n clickable: true,\n borderWidth: 1,\n markings: markings\n },\n legend: {\n show: false\n }\n };\n \n var $grade_detail_graph = $("#' ) __M_writer(js_escaped_string(graph_div_id)) __M_writer( u'");\n if ($grade_detail_graph.length > 0) {\n var plot = $.plot($grade_detail_graph, series, options);\n \n' ) if show_grade_breakdown: __M_writer(u' var o = plot.pointOffset(\n {x: ') __M_writer(dump_js_escaped_json(overviewBarX)) __M_writer(u' , y: ') __M_writer(dump_js_escaped_json(totalScore)) __M_writer( u'}\n );\n\n edx.HtmlUtils.append(\n $grade_detail_graph,\n edx.HtmlUtils.joinHtml(\n // xss-lint: disable=javascript-concat-html\n edx.HtmlUtils.HTML(\'<div class="overallGrade" style="position:absolute;left:\' + (o.left - 12) + \'px;top:\' + (o.top - 20) + \'px">\'),\n edx.HtmlUtils.HTML(\'<span class=sr>\'),\n gettext(\'Overall Score\'),\n edx.HtmlUtils.HTML(\'<br></span>\'),\n \'' ) __M_writer( js_escaped_string( '{totalscore:.0%}'.format(totalscore=totalScore))) __M_writer( u"',\n edx.HtmlUtils.HTML('</div>')\n )\n );\n\n" ) __M_writer( u'\n $grade_detail_graph.find(\'.xAxis .tickLabel\').attr(\'tabindex\', \'0\').focus(function(event) {\n var $target = $(event.target), srElements = $target.find(\'.sr\'), srText="", i;\n if (srElements.length > 0) {\n for (i = 0; i < srElements.length; i++) {\n srText += srElements[i].innerHTML;\n }\n // Position the tooltip slightly above the tick label.\n showTooltip($target.offset().left - 70, $target.offset().top - 120, srText);\n }\n });\n\n $grade_detail_graph.focusout(function(){\n $("#tooltip").remove();\n });\n }\n \n \n var previousPoint = null;\n $grade_detail_graph.bind("plothover", function (event, pos, item) {\n if (item) {\n if (previousPoint != (item.dataIndex, item.seriesIndex)) {\n previousPoint = (item.dataIndex, item.seriesIndex);\n \n if (item.series.label in detail_tooltips) {\n var series_tooltips = detail_tooltips[item.series.label];\n if (item.dataIndex < series_tooltips.length) {\n showTooltip(item.pageX, item.pageY, series_tooltips[item.dataIndex]);\n }\n }\n\n }\n } else {\n $("#tooltip").remove();\n previousPoint = null; \n }\n });\n});\n' ) return '' finally: context.caller_stack._pop_frame()
def render_body(context, **pageargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) root_url = context.get('root_url', UNDEFINED) annotated_content_info = context.get('annotated_content_info', UNDEFINED) course_settings = context.get('course_settings', UNDEFINED) roles = context.get('roles', UNDEFINED) thread_pages = context.get('thread_pages', UNDEFINED) is_commentable_divided = context.get('is_commentable_divided', UNDEFINED) sort_preference = context.get('sort_preference', UNDEFINED) user_info = context.get('user_info', UNDEFINED) threads = context.get('threads', UNDEFINED) unicode = context.get('unicode', UNDEFINED) discussion_default_topic_id = context.get( 'discussion_default_topic_id', UNDEFINED) course = context.get('course', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') __M_writer( u"\n\n(function (require, define) {\n var registerDiscussionClass = function(moduleName, modulePath) {\n define(\n modulePath,\n [],\n function() {\n var discussionClass = window[moduleName];\n if (!discussionClass) {\n throw new Error('Discussion class not loaded: ' + moduleName);\n }\n return discussionClass;\n }\n );\n }\n\n" ) __M_writer(u' ') discussion_classes = [ ['Discussion', 'common/js/discussion/discussion'], ['Content', 'common/js/discussion/content'], [ 'DiscussionModuleView', 'common/js/discussion/discussion_module_view' ], [ 'DiscussionThreadView', 'common/js/discussion/views/discussion_thread_view' ], [ 'DiscussionThreadListView', 'common/js/discussion/views/discussion_thread_list_view' ], [ 'DiscussionThreadProfileView', 'common/js/discussion/views/discussion_thread_profile_view' ], ['DiscussionUtil', 'common/js/discussion/utils'], [ 'DiscussionCourseSettings', 'common/js/discussion/models/discussion_course_settings' ], ['DiscussionUser', 'common/js/discussion/models/discussion_user'], ['NewPostView', 'common/js/discussion/views/new_post_view'], ] __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['discussion_classes'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n\n') for discussion_class_info in discussion_classes: __M_writer(u" registerDiscussionClass(\n '") __M_writer(js_escaped_string(discussion_class_info[0])) __M_writer(u"',\n '") __M_writer(js_escaped_string(discussion_class_info[1])) __M_writer(u"'\n );\n") __M_writer(u'\n') __M_writer( u" $(function() {\n require(['discussion/js/discussion_board_factory'], function (DiscussionBoardFactory) {\n DiscussionBoardFactory({\n courseId: '" ) __M_writer(js_escaped_string(unicode(course.id))) __M_writer( u'\',\n $el: $(".discussion-board"),\n rootUrl: \'' ) __M_writer(js_escaped_string(root_url)) __M_writer(u"',\n userInfo: ") __M_writer(dump_js_escaped_json(user_info)) __M_writer(u',\n roles: ') __M_writer(dump_js_escaped_json(roles)) __M_writer(u",\n sortPreference: '") __M_writer(js_escaped_string(sort_preference)) __M_writer(u"',\n threads: ") __M_writer(dump_js_escaped_json(threads)) __M_writer(u",\n threadPages: '") __M_writer(js_escaped_string(thread_pages)) __M_writer(u"',\n contentInfo: ") __M_writer(dump_js_escaped_json(annotated_content_info)) __M_writer(u",\n courseName: '") __M_writer(js_escaped_string(course.display_name_with_default)) __M_writer(u"',\n courseSettings: ") __M_writer(dump_js_escaped_json(course_settings)) __M_writer(u',\n isCommentableDivided: ') __M_writer(dump_js_escaped_json(is_commentable_divided)) __M_writer(u",\n defaultTopicId: '") __M_writer(js_escaped_string(discussion_default_topic_id)) __M_writer( u"'\n });\n });\n });\n}).call(this, require || RequireJS.require, define || RequireJS.define);\n" ) return '' finally: context.caller_stack._pop_frame()
def render_js_extra(context, **pageargs): __M_caller = context.caller_stack._push_frame() try: def js_extra(): return render_js_extra(context) static = _mako_get_namespace(context, 'static') user = context.get('user', UNDEFINED) auth = context.get('auth', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') def ccall(caller): def body(): password_reset_support_link = context.get( 'password_reset_support_link', UNDEFINED) extended_profile_fields = context.get( 'extended_profile_fields', UNDEFINED) enterprise_name = context.get('enterprise_name', UNDEFINED) user_preferences_api_url = context.get( 'user_preferences_api_url', UNDEFINED) fields = context.get('fields', UNDEFINED) enterprise_readonly_account_fields = context.get( 'enterprise_readonly_account_fields', UNDEFINED) sync_learner_profile_data = context.get( 'sync_learner_profile_data', UNDEFINED) edx_support_url = context.get('edx_support_url', UNDEFINED) bool = context.get('bool', UNDEFINED) user_accounts_api_url = context.get('user_accounts_api_url', UNDEFINED) enable_account_deletion = context.get( 'enable_account_deletion', UNDEFINED) order_history = context.get('order_history', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n var fieldsData = ') __M_writer(dump_js_escaped_json(fields)) __M_writer(u',\n ordersHistoryData = ') __M_writer(dump_js_escaped_json(order_history)) __M_writer(u',\n authData = ') __M_writer(dump_js_escaped_json(auth)) __M_writer(u",\n platformName = '") __M_writer(js_escaped_string(static.get_platform_name())) __M_writer(u"',\n contactEmail = '") __M_writer( js_escaped_string(static.get_contact_email_address())) __M_writer(u"',\n allowEmailChange = ") __M_writer( dump_js_escaped_json( bool(settings.FEATURES['ALLOW_EMAIL_ADDRESS_CHANGE']))) __M_writer(u',\n socialPlatforms = ') __M_writer(dump_js_escaped_json(settings.SOCIAL_PLATFORMS)) __M_writer(u',\n\n syncLearnerProfileData = ') __M_writer( dump_js_escaped_json(bool(sync_learner_profile_data))) __M_writer(u",\n enterpriseName = '") __M_writer(js_escaped_string(enterprise_name)) __M_writer(u"',\n enterpriseReadonlyAccountFields = ") __M_writer( dump_js_escaped_json(enterprise_readonly_account_fields)) __M_writer(u",\n edxSupportUrl = '") __M_writer(js_escaped_string(edx_support_url)) __M_writer(u"',\n extendedProfileFields = ") __M_writer(dump_js_escaped_json(extended_profile_fields)) __M_writer(u',\n displayAccountDeletion = ') __M_writer(dump_js_escaped_json(enable_account_deletion)) __M_writer(u';\n isSecondaryEmailFeatureEnabled = ') __M_writer( dump_js_escaped_json( bool(is_secondary_email_feature_enabled_for_user( user)))) __M_writer( u",\n\n AccountSettingsFactory(\n fieldsData,\n ordersHistoryData,\n authData,\n '" ) __M_writer(js_escaped_string(password_reset_support_link)) __M_writer(u"',\n '") __M_writer(js_escaped_string(user_accounts_api_url)) __M_writer(u"',\n '") __M_writer(js_escaped_string(user_preferences_api_url)) __M_writer(u"',\n ") __M_writer(dump_js_escaped_json(user.id)) __M_writer( u',\n platformName,\n contactEmail,\n allowEmailChange,\n socialPlatforms,\n\n syncLearnerProfileData,\n enterpriseName,\n enterpriseReadonlyAccountFields,\n edxSupportUrl,\n extendedProfileFields,\n displayAccountDeletion,\n isSecondaryEmailFeatureEnabled\n );\n' ) return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8( static.require_module( class_name=u'AccountSettingsFactory', module_name= u'js/student_account/views/account_settings_factory' )))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n\n<script type="text/javascript">\n window.auth = ') __M_writer(dump_js_escaped_json(auth)) __M_writer(u';\n window.isActive = ') __M_writer(dump_js_escaped_json(user.is_active)) __M_writer(u';\n</script>\n') def ccall(caller): def body(): __M_writer = context.writer() __M_writer(u'\n') return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8( static.webpack( entry=u'StudentAccountDeletionInitializer')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n') return '' finally: context.caller_stack._pop_frame()
def body(): password_reset_support_link = context.get( 'password_reset_support_link', UNDEFINED) extended_profile_fields = context.get( 'extended_profile_fields', UNDEFINED) enterprise_name = context.get('enterprise_name', UNDEFINED) user_preferences_api_url = context.get( 'user_preferences_api_url', UNDEFINED) fields = context.get('fields', UNDEFINED) enterprise_readonly_account_fields = context.get( 'enterprise_readonly_account_fields', UNDEFINED) sync_learner_profile_data = context.get( 'sync_learner_profile_data', UNDEFINED) edx_support_url = context.get('edx_support_url', UNDEFINED) bool = context.get('bool', UNDEFINED) user_accounts_api_url = context.get('user_accounts_api_url', UNDEFINED) enable_account_deletion = context.get( 'enable_account_deletion', UNDEFINED) order_history = context.get('order_history', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n var fieldsData = ') __M_writer(dump_js_escaped_json(fields)) __M_writer(u',\n ordersHistoryData = ') __M_writer(dump_js_escaped_json(order_history)) __M_writer(u',\n authData = ') __M_writer(dump_js_escaped_json(auth)) __M_writer(u",\n platformName = '") __M_writer(js_escaped_string(static.get_platform_name())) __M_writer(u"',\n contactEmail = '") __M_writer( js_escaped_string(static.get_contact_email_address())) __M_writer(u"',\n allowEmailChange = ") __M_writer( dump_js_escaped_json( bool(settings.FEATURES['ALLOW_EMAIL_ADDRESS_CHANGE']))) __M_writer(u',\n socialPlatforms = ') __M_writer(dump_js_escaped_json(settings.SOCIAL_PLATFORMS)) __M_writer(u',\n\n syncLearnerProfileData = ') __M_writer( dump_js_escaped_json(bool(sync_learner_profile_data))) __M_writer(u",\n enterpriseName = '") __M_writer(js_escaped_string(enterprise_name)) __M_writer(u"',\n enterpriseReadonlyAccountFields = ") __M_writer( dump_js_escaped_json(enterprise_readonly_account_fields)) __M_writer(u",\n edxSupportUrl = '") __M_writer(js_escaped_string(edx_support_url)) __M_writer(u"',\n extendedProfileFields = ") __M_writer(dump_js_escaped_json(extended_profile_fields)) __M_writer(u',\n displayAccountDeletion = ') __M_writer(dump_js_escaped_json(enable_account_deletion)) __M_writer(u';\n isSecondaryEmailFeatureEnabled = ') __M_writer( dump_js_escaped_json( bool(is_secondary_email_feature_enabled_for_user( user)))) __M_writer( u",\n\n AccountSettingsFactory(\n fieldsData,\n ordersHistoryData,\n authData,\n '" ) __M_writer(js_escaped_string(password_reset_support_link)) __M_writer(u"',\n '") __M_writer(js_escaped_string(user_accounts_api_url)) __M_writer(u"',\n '") __M_writer(js_escaped_string(user_preferences_api_url)) __M_writer(u"',\n ") __M_writer(dump_js_escaped_json(user.id)) __M_writer( u',\n platformName,\n contactEmail,\n allowEmailChange,\n socialPlatforms,\n\n syncLearnerProfileData,\n enterpriseName,\n enterpriseReadonlyAccountFields,\n edxSupportUrl,\n extendedProfileFields,\n displayAccountDeletion,\n isSecondaryEmailFeatureEnabled\n );\n' ) return ''
def render_body(context, **pageargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) def requirejs(): return render_requirejs(context._locals(__M_locals)) request = context.get('request', UNDEFINED) EDX_ROOT_URL = context.get('EDX_ROOT_URL', UNDEFINED) static = _mako_get_namespace(context, 'static') LANGUAGE_CODE = context.get('LANGUAGE_CODE', UNDEFINED) def bodyclass(): return render_bodyclass(context._locals(__M_locals)) def title(): return render_title(context._locals(__M_locals)) context_library = context.get('context_library', UNDEFINED) def jsextra(): return render_jsextra(context._locals(__M_locals)) def content(): return render_content(context._locals(__M_locals)) getattr = context.get('getattr', UNDEFINED) uses_bootstrap = context.get('uses_bootstrap', UNDEFINED) def view_notes(): return render_view_notes(context._locals(__M_locals)) user = context.get('user', UNDEFINED) hasattr = context.get('hasattr', UNDEFINED) context_course = context.get('context_course', UNDEFINED) settings = context.get('settings', UNDEFINED) list = context.get('list', UNDEFINED) def page_bundle(): return render_page_bundle(context._locals(__M_locals)) def page_alert(): return render_page_alert(context._locals(__M_locals)) def header_extras(): return render_header_extras(context._locals(__M_locals)) def modal_placeholder(): return render_modal_placeholder(context._locals(__M_locals)) self = context.get('self', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') __M_writer(u'\n\n') __M_writer(u'\n') __M_writer(u'\n\n') __M_writer( u'\n<!doctype html>\n<!--[if lte IE 9]><html class="ie9 lte9" lang="' ) __M_writer(filters.html_escape(filters.decode.utf8(LANGUAGE_CODE))) __M_writer(u'"><![endif]-->\n<!--[if !IE]><<!--><html lang="') __M_writer(filters.html_escape(filters.decode.utf8(LANGUAGE_CODE))) __M_writer(u'"><!--<![endif]-->\n <head dir="') __M_writer(filters.html_escape(filters.decode.utf8(static.dir_rtl()))) __M_writer( u'">\n <meta charset="utf-8">\n <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n <meta name="openedx-release-line" content="' ) __M_writer(filters.html_escape(filters.decode.utf8(RELEASE_LINE))) __M_writer(u'" />\n <title>\n ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'title'): context['self'].title(**pageargs) __M_writer(u' |\n') if context_course: __M_writer(u' ') ctx_loc = context_course.location __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['ctx_loc'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n ') __M_writer( filters.html_escape( filters.decode.utf8( context_course.display_name_with_default))) __M_writer(u' |\n') elif context_library: __M_writer(u' ') __M_writer( filters.html_escape( filters.decode.utf8( context_library.display_name_with_default))) __M_writer(u' |\n') __M_writer(u' ') __M_writer( filters.html_escape(filters.decode.utf8(settings.STUDIO_NAME))) __M_writer(u'\n </title>\n\n ') jsi18n_path = "js/i18n/{language}/djangojs.js".format( language=LANGUAGE_CODE) __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['jsi18n_path'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n\n') if getattr(settings, 'CAPTURE_CONSOLE_LOG', False): __M_writer( u' <script type="text/javascript">\n var oldOnError = window.onerror;\n window.localStorage.setItem(\'console_log_capture\', JSON.stringify([]));\n\n window.onerror = function (message, url, lineno, colno, error) {\n if (oldOnError) {\n oldOnError.apply(this, arguments);\n }\n\n var messages = JSON.parse(window.localStorage.getItem(\'console_log_capture\'));\n messages.push([message, url, lineno, colno, (error || {}).stack]);\n window.localStorage.setItem(\'console_log_capture\', JSON.stringify(messages));\n }\n </script>\n' ) __M_writer(u'\n <script type="text/javascript" src="') __M_writer( filters.html_escape(filters.decode.utf8(static.url(jsi18n_path)))) __M_writer( u'"></script>\n <meta name="viewport" content="width=device-width,initial-scale=1">\n <meta name="path_prefix" content="' ) __M_writer(filters.html_escape(filters.decode.utf8(EDX_ROOT_URL))) __M_writer(u'">\n\n ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8(static.css(group=u'style-vendor')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8( static.css(group=u'style-vendor-tinymce-content')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8( static.css(group=u'style-vendor-tinymce-skin')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n\n') if uses_bootstrap: __M_writer(u' <link rel="stylesheet" href="') __M_writer( filters.html_escape( filters.decode.utf8(static.url(self.attr.main_css)))) __M_writer(u'" type="text/css" media="all" />\n') else: __M_writer(u' ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8( static.css(group=(self.attr.main_css))))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n') __M_writer(u'\n ') runtime._include_file(context, u'widgets/segment-io.html', _template_uri) __M_writer(u'\n\n ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'header_extras'): context['self'].header_extras(**pageargs) __M_writer(u'\n </head>\n\n <body class="') __M_writer(filters.html_escape(filters.decode.utf8(static.dir_rtl()))) __M_writer(u' ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'bodyclass'): context['self'].bodyclass(**pageargs) __M_writer(u' lang_') __M_writer(filters.html_escape(filters.decode.utf8(LANGUAGE_CODE))) __M_writer(u'">\n ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'view_notes'): context['self'].view_notes(**pageargs) __M_writer(u'\n\n <a class="nav-skip" href="#main">') __M_writer( filters.html_escape(filters.decode.utf8( _("Skip to main content")))) __M_writer(u'</a>\n\n ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8(static.js(group=u'base_vendor')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n\n ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8(static.webpack(entry=u'commons')))) finally: context.caller_stack.nextcaller = None __M_writer( u'\n\n <script type="text/javascript">\n window.baseUrl = "' ) __M_writer(js_escaped_string(settings.STATIC_URL)) __M_writer( u'";\n require.config({\n baseUrl: window.baseUrl\n });\n </script>\n\n <script type="text/javascript" src="' ) __M_writer( filters.html_escape( filters.decode.utf8(static.url("cms/js/require-config.js")))) __M_writer( u'"></script>\n\n <!-- view -->\n <div class="wrapper wrapper-view" dir="' ) __M_writer(filters.html_escape(filters.decode.utf8(static.dir_rtl()))) __M_writer(u'">\n ') online_help_token = self.online_help_token() if hasattr( self, 'online_help_token') else None __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['online_help_token'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n ') runtime._include_file(context, u'widgets/header.html', _template_uri, online_help_token=online_help_token) __M_writer(u'\n\n ') banner_messages = list(PageLevelMessages.user_messages(request)) __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update( __M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['banner_messages'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n\n') if banner_messages: __M_writer( u' <div class="page-banner">\n <div class="user-messages">\n' ) for message in banner_messages: __M_writer(u' <div class="alert ') __M_writer( filters.html_escape(filters.decode.utf8( message.css_class))) __M_writer( u'" role="alert">\n <span class="icon icon-alert fa ' ) __M_writer( filters.html_escape(filters.decode.utf8( message.icon_class))) __M_writer(u'" aria-hidden="true"></span>\n ') __M_writer( filters.html_escape( filters.decode.utf8(HTML(message.message_html)))) __M_writer(u'\n </div>\n') __M_writer(u' </div>\n </div>\n') __M_writer(u'\n <div id="page-alert">\n ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'page_alert'): context['self'].page_alert(**pageargs) __M_writer( u'\n </div>\n\n <main id="main" aria-label="Content" tabindex="-1">\n <div id="content">\n ' ) if 'parent' not in context._data or not hasattr( context._data['parent'], 'content'): context['self'].content(**pageargs) __M_writer(u'\n </div>\n </main>\n\n') if user.is_authenticated: __M_writer(u' ') runtime._include_file(context, u'widgets/sock.html', _template_uri, online_help_token=online_help_token) __M_writer(u'\n') __M_writer(u' ') runtime._include_file(context, u'widgets/footer.html', _template_uri) __M_writer( u'\n\n <div id="page-notification"></div>\n </div>\n\n <div id="page-prompt"></div>\n\n ' ) if 'parent' not in context._data or not hasattr( context._data['parent'], 'modal_placeholder'): context['self'].modal_placeholder(**pageargs) __M_writer(u'\n\n ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'jsextra'): context['self'].jsextra(**pageargs) __M_writer(u'\n\n') if context_course: __M_writer(u' ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8( static.webpack( entry=u'js/factories/context_course')))) finally: context.caller_stack.nextcaller = None __M_writer( u'\n <script type="text/javascript">\n window.course = new ContextCourse({\n id: "' ) __M_writer(js_escaped_string(context_course.id)) __M_writer(u'",\n name: "') __M_writer( js_escaped_string(context_course.display_name_with_default)) __M_writer(u'",\n url_name: "') __M_writer(js_escaped_string(context_course.location.block_id)) __M_writer(u'",\n org: "') __M_writer(js_escaped_string(context_course.location.org)) __M_writer(u'",\n num: "') __M_writer(js_escaped_string(context_course.location.course)) __M_writer(u'",\n display_course_number: "') __M_writer(js_escaped_string(context_course.display_coursenumber)) __M_writer(u'",\n revision: "') __M_writer(js_escaped_string(context_course.location.branch)) __M_writer(u'",\n self_paced: ') __M_writer(dump_js_escaped_json(context_course.self_paced)) __M_writer(u'\n });\n </script>\n') if user.is_authenticated: __M_writer(u' ') def ccall(caller): def body(): __M_writer = context.writer() return '' return [body] context.caller_stack.nextcaller = runtime.Namespace( 'caller', context, callables=ccall(__M_caller)) try: __M_writer( filters.html_escape( filters.decode.utf8(static.webpack(entry=u'js/sock')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n') __M_writer(u' ') if 'parent' not in context._data or not hasattr( context._data['parent'], 'page_bundle'): context['self'].page_bundle(**pageargs) __M_writer(u'\n ') runtime._include_file(context, u'widgets/segment-io-footer.html', _template_uri) __M_writer( u'\n <div class="modal-cover"></div>\n </body>\n</html>\n') return '' finally: context.caller_stack._pop_frame()
def get(self, request, *args, **kwargs): """Returns organization list as json.""" organizations = get_organizations() org_names_list = [(org["short_name"]) for org in organizations] return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8')
def body(): __M_writer = context.writer() __M_writer(u'\n PreviewFactory(') __M_writer(dump_js_escaped_json(preview_options)) __M_writer(u');\n ') return ''