当前位置: 首页>>代码示例>>Python>>正文


Python Scope.settings方法代码示例

本文整理汇总了Python中xblock.fields.Scope.settings方法的典型用法代码示例。如果您正苦于以下问题:Python Scope.settings方法的具体用法?Python Scope.settings怎么用?Python Scope.settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xblock.fields.Scope的用法示例。


在下文中一共展示了Scope.settings方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: studio_view

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def studio_view(self, context):
        """
        Render a form for editing this XBlock
        """
        fragment = Fragment()
        context = {'fields': []}
        # Build a list of all the fields that can be edited:
        for field_name in self.editable_fields:
            field = self.fields[field_name]
            assert field.scope in (Scope.content, Scope.settings), (
                "Only Scope.content or Scope.settings fields can be used with "
                "StudioEditableXBlockMixin. Other scopes are for user-specific data and are "
                "not generally created/configured by content authors in Studio."
            )
            field_info = self._make_field_info(field_name, field)
            if field_info is not None:
                context["fields"].append(field_info)
        fragment.content = loader.render_django_template('templates/studio_edit.html', context)
        fragment.add_javascript(loader.load_unicode('public/studio_edit.js'))
        fragment.initialize_js('StudioEditableXBlockMixin')
        return fragment 
开发者ID:edx,项目名称:xblock-utils,代码行数:23,代码来源:studio_editable.py

示例2: studio_submit

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def studio_submit(self, submissions, suffix=''):  # pylint: disable=unused-argument
        """
        Change the settings for this XBlock given by the Studio user
        """
        if not isinstance(submissions, dict):
            LOG.error("submissions object from Studio is not a dict - %r", submissions)
            return {
                'result': 'error'
            }

        if 'display_name' in submissions:
            self.display_name = submissions['display_name']
        if 'embed_code' in submissions:
            self.embed_code = submissions['embed_code']
        if 'alt_text' in submissions:
            self.alt_text = submissions['alt_text']

        return {
            'result': 'success',
        }

    # suffix argument is specified for xblocks, but we are not using herein 
开发者ID:edx-solutions,项目名称:xblock-google-drive,代码行数:24,代码来源:google_docs.py

示例3: studio_submit

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def studio_submit(self, submissions, suffix=''):  # pylint: disable=unused-argument
        """
        Change the settings for this XBlock given by the Studio user
        """
        if not isinstance(submissions, dict):
            LOG.error("submissions object from Studio is not a dict - %r", submissions)
            return {
                'result': 'error'
            }

        if 'display_name' in submissions:
            self.display_name = submissions['display_name']
        if 'calendar_id' in submissions:
            self.calendar_id = submissions['calendar_id']
        if 'default_view' in submissions:
            self.default_view = submissions['default_view']

        return {
            'result': 'success',
        } 
开发者ID:edx-solutions,项目名称:xblock-google-drive,代码行数:22,代码来源:google_calendar.py

示例4: fetch

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def fetch(cls, descriptor):
        """
        Fetch the key:value editable course details for the given course from
        persistence and return a CourseMetadata model.
        """
        result = {}

        for field in descriptor.fields.values():
            if field.scope != Scope.settings:
                continue

            if field.name in cls.filtered_list():
                continue

            result[field.name] = {
                'value': field.read_json(descriptor),
                'display_name': _(field.display_name),
                'help': _(field.help),
                'deprecated': field.runtime_options.get('deprecated', False)
            }

        return result 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:24,代码来源:course_metadata.py

示例5: __init__

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def __init__(self, authored_data, student_data):
        # Make sure that we don't repeatedly nest CmsFieldData instances
        if isinstance(authored_data, CmsFieldData):
            authored_data = authored_data._authored_data  # pylint: disable=protected-access

        self._authored_data = authored_data
        self._student_data = student_data

        super(CmsFieldData, self).__init__({
            Scope.content: authored_data,
            Scope.settings: authored_data,
            Scope.parent: authored_data,
            Scope.children: authored_data,
            Scope.user_state_summary: student_data,
            Scope.user_state: student_data,
            Scope.user_info: student_data,
            Scope.preferences: student_data,
        }) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:20,代码来源:field_data.py

示例6: get_attribute_or_default

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def get_attribute_or_default(self, attribute_name):
        """
        If the given attribute is set on the instance, return it immediately.
        Otherwise check if it has a default in the settings service.
        If neither are available, return None
        """
        try:
            available_attr = getattr(self, attribute_name)
        except AttributeError:
            available_attr = None

        if available_attr:
            return available_attr

        if getattr(self.runtime, 'service') and hasattr(self, 'service_declaration'):
            settings_service = self.runtime.service(self, 'settings')
            if settings_service:
                setting_name = self.DEFAULT_ATTRIBUTE_SETTINGS[attribute_name]
                return settings_service.get_settings_bucket(self).get(setting_name)
        return available_attr  # Ensures that the field's default type is preserved 
开发者ID:edx-solutions,项目名称:xblock-ooyala,代码行数:22,代码来源:ooyala_player.py

示例7: student_view

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def student_view(self, context=None):
        context_html = self.get_context_student()
        template = self.render_template('static/html/scormxblock.html', context_html)
        frag = Fragment(template)
        frag.add_css(self.resource_string("static/css/scormxblock.css"))
        frag.add_javascript(self.resource_string("static/js/src/scormxblock.js"))
        settings = {
            'version_scorm': self.version_scorm
        }
        frag.initialize_js('ScormXBlock', json_args=settings)
        return frag 
开发者ID:raccoongang,项目名称:edx_xblock_scorm,代码行数:13,代码来源:scormxblock.py

示例8: get_context_student

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def get_context_student(self):
        scorm_file_path = ''
        if self.scorm_file:
            scheme = 'https' if settings.HTTPS == 'on' else 'http'
            scorm_file_path = '{}://{}{}'.format(
                scheme,
                configuration_helpers.get_value('site_domain', settings.ENV_TOKENS.get('LMS_BASE')),
                self.scorm_file
            )

        return {
            'scorm_file_path': scorm_file_path,
            'completion_status': self.get_completion_status(),
            'scorm_xblock': self
        } 
开发者ID:raccoongang,项目名称:edx_xblock_scorm,代码行数:17,代码来源:scormxblock.py

示例9: filtered_list

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def filtered_list(cls):
        """
        Filter fields based on feature flag, i.e. enabled, disabled.
        """
        # Copy the filtered list to avoid permanently changing the class attribute.
        filtered_list = list(cls.FILTERED_LIST)

        # Do not show giturl if feature is not enabled.
        if not settings.FEATURES.get('ENABLE_EXPORT_GIT'):
            filtered_list.append('giturl')

        return filtered_list 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:14,代码来源:course_metadata.py

示例10: student_view_data

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def student_view_data(self, context=None):
        """
        Returns a dict containing the settings for the student view.

        Returns:
            E.g.,
                {
                  "player_token": "http://player.ooyala.com/sas/embed_token/53YWsyOszKOsfS1...",
                  "player_token_expires": 1501812713,
                  "partner_code: "53YWsyOszKOsfS1IvcQoKn8YhWYk",
                  "content_id": "5sMHA1YzE6KHI-dFSKgDz-pcMOx37_f9",
                  "player_type": "bcove",
                  "bcove_id": "6068615189001"
                }

            See player_token() for more information on the player_token_* fields.
        """
        data = self.player_token()
        data.update({
            'partner_code': self.get_attribute_or_default('partner_code'),
            'content_id': self.reference_id or self.content_id,
            'player_type': VideoType.BRIGHTCOVE if self.is_brightcove_video else VideoType.OOYALA,
            'bcove_id': self.content_id if self.is_brightcove_video else None,
            'bcove_account_id': self.get_attribute_or_default('brightcove_account'),
            'bcove_policy': self.get_attribute_or_default('brightcove_policy'),
        })

        return data 
开发者ID:edx-solutions,项目名称:xblock-ooyala,代码行数:30,代码来源:ooyala_player.py

示例11: brightcove_policy

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def brightcove_policy(self):
        xblock_settings = settings.XBLOCK_SETTINGS if hasattr(settings, "XBLOCK_SETTINGS") else {}
        return xblock_settings.get('OoyalaPlayerBlock', {}).get('BCOVE_POLICY') 
开发者ID:edx-solutions,项目名称:xblock-ooyala,代码行数:5,代码来源:ooyala_player.py

示例12: brightcove_account

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def brightcove_account(self):
        xblock_settings = settings.XBLOCK_SETTINGS if hasattr(settings, "XBLOCK_SETTINGS") else {}
        return xblock_settings.get('OoyalaPlayerBlock', {}).get('BCOVE_ACCOUNT_ID') 
开发者ID:edx-solutions,项目名称:xblock-ooyala,代码行数:5,代码来源:ooyala_player.py

示例13: local_resource_url

# 需要导入模块: from xblock.fields import Scope [as 别名]
# 或者: from xblock.fields.Scope import settings [as 别名]
def local_resource_url(self, block, uri):
        """
        local_resource_url for xblocks, with lightchild support.
        """
        path = reverse('xblock_resource_url', kwargs={
            'block_type': block.lightchild_block_type or block.scope_ids.block_type,
            'uri': uri,
        })
        return '//{}{}'.format(settings.SITE_NAME, path) 
开发者ID:edx-solutions,项目名称:xblock-ooyala,代码行数:11,代码来源:ooyala_player.py


注:本文中的xblock.fields.Scope.settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。