Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cms/djangoapps/contentstore/views/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def _preview_module_system(request, descriptor, field_data):
preview_anonymous_user_id = anonymous_id_for_user(request.user, course_id)

return PreviewModuleSystem(
static_url=settings.STATIC_URL,
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
track_function=lambda event_type, event: None,
get_module=partial(_load_preview_module, request),
Expand Down
1 change: 0 additions & 1 deletion lms/djangoapps/courseware/module_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ def handle_deprecated_progress_event(block, event):

system = LmsModuleSystem(
track_function=track_function,
static_url=settings.STATIC_URL,
get_module=inner_get_module,
user=user,
publish=publish,
Expand Down
4 changes: 0 additions & 4 deletions lms/djangoapps/lms_xblock/test/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def setUp(self):
self.block = BlockMock(name='block', scope_ids=ScopeIds(None, None, None, 'dummy'))
self.course_key = CourseLocator("org", "course", "run")
self.runtime = LmsModuleSystem(
static_url='/static',
track_function=Mock(),
get_module=Mock(),
course_id=self.course_key,
Expand Down Expand Up @@ -125,7 +124,6 @@ def setUp(self):
self.user = UserFactory.create()

self.runtime = LmsModuleSystem(
static_url='/static',
track_function=Mock(),
get_module=Mock(),
user=self.user,
Expand Down Expand Up @@ -175,7 +173,6 @@ def create_runtime(self):
Create the testing runtime.
"""
return LmsModuleSystem(
static_url='/static',
track_function=Mock(),
get_module=Mock(),
course_id=self.course_id,
Expand Down Expand Up @@ -229,7 +226,6 @@ def setUp(self):
self.course = CourseFactory.create()
self.test_language = 'dummy language'
self.runtime = LmsModuleSystem(
static_url='/static',
track_function=Mock(),
get_module=Mock(),
course_id=self.course.id,
Expand Down
14 changes: 7 additions & 7 deletions openedx/core/djangoapps/xblock/runtime/shims.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
# pylint: disable=no-member

import warnings

from django.conf import settings
from django.core.cache import cache
from django.template import TemplateDoesNotExist
from django.utils.functional import cached_property
from fs.memoryfs import MemoryFS

from openedx.core.djangoapps.xblock.apps import get_xblock_app_config

from common.djangoapps.static_replace.services import ReplaceURLService
from common.djangoapps.edxmako.shortcuts import render_to_string
from common.djangoapps.static_replace.services import ReplaceURLService
from common.djangoapps.student.models import anonymous_id_for_user
from openedx.core.djangoapps.xblock.apps import get_xblock_app_config


class RuntimeShim:
Expand Down Expand Up @@ -235,10 +233,12 @@ def seed(self):
def STATIC_URL(self):
"""
Get the django STATIC_URL path.

Seems only to be used by capa. Remove this if capa can be refactored.
Deprecated in favor of the settings.STATIC_URL configuration.
"""
# TODO: Refactor capa to access this directly, don't bother the runtime. Then remove it from here.
warnings.warn(
'runtime.STATIC_URL is deprecated. Please use settings.STATIC_URL instead.',
DeprecationWarning, stacklevel=3,
)
static_url = settings.STATIC_URL
if static_url.startswith('/') and not static_url.startswith('//'):
# This is not a full URL - should start with https:// to support loading assets from an iframe sandbox
Expand Down
4 changes: 2 additions & 2 deletions xmodule/capa/capa_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from xml.sax.saxutils import unescape

import six
from django.conf import settings

from lxml import etree
from pytz import UTC
Expand Down Expand Up @@ -107,7 +108,6 @@ def __init__(
render_template,
resources_fs,
seed, # Why do we do this if we have self.seed?
STATIC_URL,
xqueue,
matlab_api_key=None
):
Expand All @@ -121,7 +121,7 @@ def __init__(
self.render_template = render_template
self.resources_fs = resources_fs
self.seed = seed # Why do we do this if we have self.seed?
self.STATIC_URL = STATIC_URL # pylint: disable=invalid-name
self.STATIC_URL = settings.STATIC_URL # pylint: disable=invalid-name
self.xqueue = xqueue
self.matlab_api_key = matlab_api_key

Expand Down
3 changes: 0 additions & 3 deletions xmodule/capa_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ def max_score(self):
render_template=None,
resources_fs=self.runtime.resources_fs,
seed=None,
STATIC_URL=None,
xqueue=None,
matlab_api_key=None,
)
Expand Down Expand Up @@ -691,7 +690,6 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
render_template=None,
resources_fs=self.runtime.resources_fs,
seed=1,
STATIC_URL=None,
xqueue=None,
matlab_api_key=None,
)
Expand Down Expand Up @@ -839,7 +837,6 @@ def new_lcp(self, state, text=None):
render_template=self.runtime.service(self, 'mako').render_template,
resources_fs=self.runtime.resources_fs,
seed=seed, # Why do we do this if we have self.seed?
STATIC_URL=self.runtime.STATIC_URL,
xqueue=self.runtime.service(self, 'xqueue'),
matlab_api_key=self.matlab_api_key
)
Expand Down
1 change: 0 additions & 1 deletion xmodule/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def get_module(descriptor):
return descriptor

return TestModuleSystem(
static_url='/static',
track_function=Mock(name='get_test_system.track_function'),
get_module=get_module,
services={
Expand Down
17 changes: 13 additions & 4 deletions xmodule/x_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,19 @@ def rebind_noauth_module_to_user(self):
if rebind_user_service:
return partial(rebind_user_service.rebind_noauth_module_to_user)

# noinspection PyPep8Naming
@property
def STATIC_URL(self): # pylint: disable=invalid-name
"""
Returns the base URL for static assets.
Deprecated in favor of the settings.STATIC_URL configuration.
"""
warnings.warn(
'runtime.STATIC_URL is deprecated. Please use settings.STATIC_URL instead.',
DeprecationWarning, stacklevel=3,
)
return settings.STATIC_URL


class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, ModuleSystemShim, Runtime):
"""
Expand All @@ -1721,7 +1734,6 @@ class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, ModuleSystemShim,

def __init__(
self,
static_url,
track_function,
get_module,
descriptor_runtime,
Expand All @@ -1732,8 +1744,6 @@ def __init__(
"""
Create a closure around the system environment.

static_url - the base URL to static assets

track_function - function of (event_type, event), intended for logging
or otherwise tracking the event.
TODO: Not used, and has inconsistent args in different
Expand All @@ -1754,7 +1764,6 @@ def __init__(
kwargs.setdefault('id_generator', getattr(descriptor_runtime, 'id_generator', AsideKeyGenerator()))
super().__init__(**kwargs)

self.STATIC_URL = static_url
self.track_function = track_function
self.get_module = get_module
self.course_id = course_id
Expand Down