Commit 3560c025 by E. Kolpakov

SettingsService for accessing server-wide settings from XBlock

(cherry picked from commit aa3b9dc)
parent 7a6d9b27
...@@ -326,3 +326,5 @@ NOTIFICATION_MAX_LIST_SIZE = ENV_TOKENS.get('NOTIFICATION_MAX_LIST_SIZE', NOTIFI ...@@ -326,3 +326,5 @@ NOTIFICATION_MAX_LIST_SIZE = ENV_TOKENS.get('NOTIFICATION_MAX_LIST_SIZE', NOTIFI
#date format the api will be formatting the datetime values #date format the api will be formatting the datetime values
API_DATE_FORMAT = '%Y-%m-%d' API_DATE_FORMAT = '%Y-%m-%d'
API_DATE_FORMAT = ENV_TOKENS.get('API_DATE_FORMAT', API_DATE_FORMAT) API_DATE_FORMAT = ENV_TOKENS.get('API_DATE_FORMAT', API_DATE_FORMAT)
XBLOCK_SETTINGS = ENV_TOKENS.get('XBLOCK_SETTINGS', {})
"""
XBlock service to allow to access the server settings
"""
from django.conf import settings
class SettingsService(object):
def get(self, setting_name):
return getattr(settings, setting_name)
...@@ -5,16 +5,15 @@ Module implementing `xblock.runtime.Runtime` functionality for the LMS ...@@ -5,16 +5,15 @@ Module implementing `xblock.runtime.Runtime` functionality for the LMS
import re import re
import xblock.reference.plugins import xblock.reference.plugins
from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from lms.djangoapps.lms_xblock.models import XBlockAsidesConfig from lms.djangoapps.lms_xblock.models import XBlockAsidesConfig
from openedx.core.djangoapps.user_api.api import course_tag as user_course_tag_api from openedx.core.djangoapps.user_api.api import course_tag as user_course_tag_api
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.services import SettingsService
from xmodule.library_tools import LibraryToolsService from xmodule.library_tools import LibraryToolsService
from xmodule.x_module import ModuleSystem from xmodule.x_module import ModuleSystem
from xmodule.partitions.partitions_service import PartitionService from xmodule.partitions.partitions_service import PartitionService
from xmodule.settings_service import SettingsService
def _quote_slashes(match): def _quote_slashes(match):
...@@ -259,7 +258,6 @@ class LmsModuleSystem(LmsHandlerUrls, LmsCourse, LmsUser, ModuleSystem): # pyli ...@@ -259,7 +258,6 @@ class LmsModuleSystem(LmsHandlerUrls, LmsCourse, LmsUser, ModuleSystem): # pyli
""" """
def __init__(self, **kwargs): def __init__(self, **kwargs):
services = kwargs.setdefault('services', {}) services = kwargs.setdefault('services', {})
services['settings'] = SettingsService()
services['user_tags'] = UserTagsService(self) services['user_tags'] = UserTagsService(self)
services['partitions'] = LmsPartitionService( services['partitions'] = LmsPartitionService(
user=kwargs.get('user'), user=kwargs.get('user'),
...@@ -268,6 +266,7 @@ class LmsModuleSystem(LmsHandlerUrls, LmsCourse, LmsUser, ModuleSystem): # pyli ...@@ -268,6 +266,7 @@ class LmsModuleSystem(LmsHandlerUrls, LmsCourse, LmsUser, ModuleSystem): # pyli
) )
services['library_tools'] = LibraryToolsService(modulestore()) services['library_tools'] = LibraryToolsService(modulestore())
services['fs'] = xblock.reference.plugins.FSService() services['fs'] = xblock.reference.plugins.FSService()
services['settings'] = SettingsService()
self.request_token = kwargs.pop('request_token', None) self.request_token = kwargs.pop('request_token', None)
super(LmsModuleSystem, self).__init__(**kwargs) super(LmsModuleSystem, self).__init__(**kwargs)
......
...@@ -573,3 +573,5 @@ NOTIFICATION_CHANNEL_PROVIDER_TYPE_MAPS = ENV_TOKENS.get( ...@@ -573,3 +573,5 @@ NOTIFICATION_CHANNEL_PROVIDER_TYPE_MAPS = ENV_TOKENS.get(
NOTIFICATION_CHANNEL_PROVIDER_TYPE_MAPS NOTIFICATION_CHANNEL_PROVIDER_TYPE_MAPS
) )
NOTIFICATION_MAX_LIST_SIZE = ENV_TOKENS.get('NOTIFICATION_MAX_LIST_SIZE', NOTIFICATION_MAX_LIST_SIZE) NOTIFICATION_MAX_LIST_SIZE = ENV_TOKENS.get('NOTIFICATION_MAX_LIST_SIZE', NOTIFICATION_MAX_LIST_SIZE)
XBLOCK_SETTINGS = ENV_TOKENS.get('XBLOCK_SETTINGS', {})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment