Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def settings(request):
blocks = {
'edx/test/verticala': XBlock.load_class('vertical')(DebuggerRuntime(), {}, {}, {}, {}),
'edx/test/verticalb': XBlock.load_class('vertical')(DebuggerRuntime(), {}, {}, {}, {}),
}
course_usages = Usage('course', 'edx/test/course', {
'graded': True,
'start_date': '1/2/12',
}, [
Usage('verticala', 'edx/test/verticala', {}, []),
Usage('verticalb', 'edx/test/verticalb', {}, [])
]).as_json()
course = XBlock.load_class('course')(DebuggerRuntime(), {
'policy_list': [{'class': 'cascade', 'params': {'keys': ['graded']}}],
'usage_tree': course_usages,
}, {}, {}, {})
def settings(request):
blocks = {
'edx/test/verticala': XBlock.load_class('vertical')(DebuggerRuntime(), {}, {}, {}, {}),
'edx/test/verticalb': XBlock.load_class('vertical')(DebuggerRuntime(), {}, {}, {}, {}),
}
course_usages = Usage('course', 'edx/test/course', {
'graded': True,
'start_date': '1/2/12',
}, [
Usage('verticala', 'edx/test/verticala', {}, []),
Usage('verticalb', 'edx/test/verticalb', {}, [])
]).as_json()
course = XBlock.load_class('course')(DebuggerRuntime(), {
'policy_list': [{'class': 'cascade', 'params': {'keys': ['graded']}}],
'usage_tree': course_usages,
}, {}, {}, {})
return render_to_response('settings.html', {
def get(self, block_type, resource):
xblock_class = xblock.core.XBlock.load_class(block_type)
mimetype = mimetypes.guess_type(resource)[0]
if mimetype is None:
mimetype = 'application/octet-stream'
self.response.status = 200
self.response.headers['Content-Type'] = mimetype
self.response.cache_control.no_cache = None
self.response.cache_control.public = 'public'
self.response.cache_control.max_age = 600
self.response.write(xblock_class.open_local_resource(resource).read())
def load_block_type(self, block_type):
"""
Returns a subclass of :class:`.XBlock` that corresponds to the specified `block_type`.
"""
return XBlock.load_class(block_type, self.default_class, self.select)
def package_resource(_request, block_type, resource):
"""
Wrapper for `pkg_resources` that tries to access a resource and, if it
is not found, raises an Http404 error.
"""
try:
xblock_class = XBlock.load_class(block_type)
content = xblock_class.open_local_resource(resource)
except Exception: # pylint: disable-msg=broad-except
raise Http404
mimetype, _ = mimetypes.guess_type(resource)
return HttpResponse(content, mimetype=mimetype)
def settings(request):
blocks = {
'edx/test/verticala': XBlock.load_class('vertical')(DebuggerRuntime(), {}, {}, {}, {}),
'edx/test/verticalb': XBlock.load_class('vertical')(DebuggerRuntime(), {}, {}, {}, {}),
}
course_usages = Usage('course', 'edx/test/course', {
'graded': True,
'start_date': '1/2/12',
}, [
Usage('verticala', 'edx/test/verticala', {}, []),
Usage('verticalb', 'edx/test/verticalb', {}, [])
]).as_json()
course = XBlock.load_class('course')(DebuggerRuntime(), {
'policy_list': [{'class': 'cascade', 'params': {'keys': ['graded']}}],
'usage_tree': course_usages,
}, {}, {}, {})
return render_to_response('settings.html', {
'base_tree': json.dumps(course.usage_tree.as_json(), indent=4),
'applied_tree': json.dumps(course.apply_policies(User()).as_json(), indent=4),
})