Allow non-public XBlock assets in debug mode

This commit is contained in:
Andy Armstrong
2015-10-19 12:28:48 -04:00
parent d4f2fe1281
commit 054aa95b26
7 changed files with 17 additions and 22 deletions

View File

@@ -1,33 +0,0 @@
"""
Views dedicated to rendering xblocks.
"""
from __future__ import absolute_import
import logging
import mimetypes
from xblock.core import XBlock
from django.conf import settings
from django.http import Http404, HttpResponse
log = logging.getLogger(__name__)
def xblock_resource(request, block_type, uri): # pylint: disable=unused-argument
"""
Return a package resource for the specified XBlock.
"""
try:
xblock_class = XBlock.load_class(block_type, select=settings.XBLOCK_SELECT_FUNCTION)
content = xblock_class.open_local_resource(uri)
except IOError:
log.info('Failed to load xblock resource', exc_info=True)
raise Http404
except Exception: # pylint: disable=broad-except
log.error('Failed to load xblock resource', exc_info=True)
raise Http404
mimetype, _ = mimetypes.guess_type(uri)
return HttpResponse(content, mimetype=mimetype)

View File

@@ -711,6 +711,9 @@ INSTALLED_APPS = (
'south',
'method_override',
# Common views
'openedx.core.djangoapps.common_views',
# History tables
'simple_history',

View File

@@ -32,7 +32,7 @@ urlpatterns = patterns(
'contentstore.views.component_handler', name='component_handler'),
url(r'^xblock/resource/(?P<block_type>[^/]*)/(?P<uri>.*)$',
'contentstore.views.xblock.xblock_resource', name='xblock_resource_url'),
'openedx.core.djangoapps.common_views.xblock.xblock_resource', name='xblock_resource_url'),
# temporary landing page for a course
url(r'^edge/(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)$',