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


Python StaticContent.get_base_url_path_for_course_assets方法代码示例

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


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

示例1: course_info_handler

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def course_info_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
    """
    GET
        html: return html for editing the course info handouts and updates.
    """
    __, course_module = _get_locator_and_course(
        package_id, branch, version_guid, block, request.user
    )
    if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):
        handouts_old_location = course_module.location.replace(category='course_info', name='handouts')
        handouts_locator = loc_mapper().translate_location(
            course_module.location.course_id, handouts_old_location, False, True
        )

        update_location = course_module.location.replace(category='course_info', name='updates')
        update_locator = loc_mapper().translate_location(
            course_module.location.course_id, update_location, False, True
        )

        return render_to_response(
            'course_info.html',
            {
                'context_course': course_module,
                'updates_url': update_locator.url_reverse('course_info_update/'),
                'handouts_locator': handouts_locator,
                'base_asset_url': StaticContent.get_base_url_path_for_course_assets(course_module.location) + '/'
            }
        )
    else:
        return HttpResponseBadRequest("Only supports html requests")
开发者ID:robertlight,项目名称:edx-platform,代码行数:32,代码来源:course.py

示例2: course_info_handler

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def course_info_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
    """
    GET
        html: return html for editing the course info handouts and updates.
    """
    course_location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, usage_id=block)
    course_old_location = loc_mapper().translate_locator_to_location(course_location)
    if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):
        if not has_access(request.user, course_location):
            raise PermissionDenied()

        course_module = modulestore().get_item(course_old_location)

        handouts_old_location = course_old_location.replace(category='course_info', name='handouts')
        handouts_locator = loc_mapper().translate_location(
            course_old_location.course_id, handouts_old_location, False, True
        )

        update_location = course_old_location.replace(category='course_info', name='updates')
        update_locator = loc_mapper().translate_location(
            course_old_location.course_id, update_location, False, True
        )

        return render_to_response(
            'course_info.html',
            {
                'context_course': course_module,
                'updates_url': update_locator.url_reverse('course_info_update/'),
                'handouts_locator': handouts_locator,
                'base_asset_url': StaticContent.get_base_url_path_for_course_assets(course_old_location) + '/'
            }
        )
    else:
        return HttpResponseBadRequest("Only supports html requests")
开发者ID:e-ucm,项目名称:edx-platform,代码行数:36,代码来源:course.py

示例3: get_html

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
    def get_html(self):
        if isinstance(modulestore(), MongoModuleStore):
            caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location) + '/subs_'
        else:
            # VS[compat]
            # cdodge: filesystem static content support.
            caption_asset_path = "/static/subs/"

        get_ext = lambda filename: filename.rpartition('.')[-1]
        sources = {get_ext(src): src for src in self.html5_sources}
        sources['main'] = self.source

        return self.system.render_template('videoalpha.html', {
            'youtube_streams': _create_youtube_string(self),
            'id': self.location.html_id(),
            'sub': self.sub,
            'sources': sources,
            'track': self.track,
            'display_name': self.display_name_with_default,
            # This won't work when we move to data that
            # isn't on the filesystem
            'data_dir': getattr(self, 'data_dir', None),
            'caption_asset_path': caption_asset_path,
            'show_captions': json.dumps(self.show_captions),
            'start': self.start_time,
            'end': self.end_time,
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True)
        })
开发者ID:burngeek8,项目名称:edx-platform,代码行数:30,代码来源:videoalpha_module.py

示例4: course_info_handler

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def course_info_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
    """
    GET
        html: return html for editing the course info handouts and updates.
    """
    __, course_module = _get_locator_and_course(package_id, branch, version_guid, block, request.user)
    if "text/html" in request.META.get("HTTP_ACCEPT", "text/html"):
        handouts_old_location = course_module.location.replace(category="course_info", name="handouts")
        handouts_locator = loc_mapper().translate_location(
            course_module.location.course_id, handouts_old_location, False, True
        )

        update_location = course_module.location.replace(category="course_info", name="updates")
        update_locator = loc_mapper().translate_location(course_module.location.course_id, update_location, False, True)

        return render_to_response(
            "course_info.html",
            {
                "context_course": course_module,
                "updates_url": update_locator.url_reverse("course_info_update/"),
                "handouts_locator": handouts_locator,
                "base_asset_url": StaticContent.get_base_url_path_for_course_assets(course_module.location) + "/",
            },
        )
    else:
        return HttpResponseBadRequest("Only supports html requests")
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:28,代码来源:course.py

示例5: get_html

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
    def get_html(self):
        if isinstance(modulestore(), MongoModuleStore):
            caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location) + "/subs_"
        else:
            # VS[compat]
            # cdodge: filesystem static content support.
            caption_asset_path = "/static/subs/"

        return self.system.render_template(
            "videoalpha.html",
            {
                "youtube_streams": self.youtube_streams,
                "id": self.location.html_id(),
                "sub": self.sub,
                "autoplay": self.autoplay,
                "sources": self.sources,
                "track": self.track,
                "display_name": self.display_name_with_default,
                # This won't work when we move to data that
                # isn't on the filesystem
                "data_dir": getattr(self, "data_dir", None),
                "caption_asset_path": caption_asset_path,
                "show_captions": self.show_captions,
                "start": self.start_time,
                "end": self.end_time,
                "autoplay": settings.MITX_FEATURES.get("AUTOPLAY_VIDEOS", True),
            },
        )
开发者ID:nageshgoyal,项目名称:edx-platform,代码行数:30,代码来源:videoalpha_module.py

示例6: get_context

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
	def get_context(self):
		_context = EditingDescriptor.get_context(self)
		_context.update({'test':self.data})
		if self.data == u'':
			template_data='<poll_compare><compare compare_id="compare_1" from_loc="i4x://[org]/[course]/[category]/[url_name]" to_loc="i4x://[org]/[course]/[category]/[url_name]" display_name="test1"></compare><compare compare_id="compare_2" from_loc="i4x://[org]/[course]/[category]/[url_name]" to_loc="i4x://[org]/[course]/[category]/[url_name]" display_name="test2"></compare></poll_compare>'
			_context.update({'test':template_data})
		_context.update({'base_asset_url': StaticContent.get_base_url_path_for_course_assets(self.location) + '/'})
		return _context
开发者ID:EduPepperPD,项目名称:pepper2013,代码行数:10,代码来源:poll_compare_module.py

示例7: get_context

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
 def get_context(self):
     """
     an override to add in specific rendering context, in this case we need to
     add in a base path to our c4x content addressing scheme
     """
     _context = EditingDescriptor.get_context(self)
     # Add some specific HTML rendering context when editing HTML modules where we pass
     # the root /c4x/ url for assets. This allows client-side substitutions to occur.
     _context.update({'base_asset_url': StaticContent.get_base_url_path_for_course_assets(self.location) + '/'})
     return _context
开发者ID:EduPepperPDTesting,项目名称:pepper2013-testing,代码行数:12,代码来源:html_module.py

示例8: rewrite_nonportable_content_links

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
    """
    Does a regex replace on non-portable links:
         /c4x/<org>/<course>/asset/<name> -> /static/<name>
         /jump_to/i4x://<org>/<course>/<category>/<name> -> /jump_to_id/<id>

    """

    def portable_asset_link_subtitution(match):
        quote = match.group('quote')
        rest = match.group('rest')
        return quote + '/static/' + rest + quote

    def portable_jump_to_link_substitution(match):
        quote = match.group('quote')
        rest = match.group('rest')
        return quote + '/jump_to_id/' + rest + quote

    # NOTE: ultimately link updating is not a hard requirement, so if something blows up with
    # the regex substitution, log the error and continue
    c4x_link_base = StaticContent.get_base_url_path_for_course_assets(source_course_id)
    try:
        text = re.sub(_prefix_only_url_replace_regex(c4x_link_base), portable_asset_link_subtitution, text)
    except Exception as exc:  # pylint: disable=broad-except
        logging.warning("Error producing regex substitution %r for text = %r.\n\nError msg = %s", c4x_link_base, text, str(exc))

    jump_to_link_base = u'/courses/{course_key_string}/jump_to/i4x://{course_key.org}/{course_key.course}/'.format(
        course_key_string=source_course_id.to_deprecated_string(), course_key=source_course_id
    )
    try:
        text = re.sub(_prefix_and_category_url_replace_regex(jump_to_link_base), portable_jump_to_link_substitution, text)
    except Exception as exc:  # pylint: disable=broad-except
        logging.warning("Error producing regex substitution %r for text = %r.\n\nError msg = %s", jump_to_link_base, text, str(exc))

    # Also, there commonly is a set of link URL's used in the format:
    # /courses/<org>/<course>/<name> which will be broken if migrated to a different course_id
    # so let's rewrite those, but the target will also be non-portable,
    #
    # Note: we only need to do this if we are changing course-id's
    #
    if source_course_id != dest_course_id:
        try:
            generic_courseware_link_base = u'/courses/{}/'.format(source_course_id.to_deprecated_string())
            text = re.sub(_prefix_only_url_replace_regex(generic_courseware_link_base), portable_asset_link_subtitution, text)
        except Exception as exc:  # pylint: disable=broad-except
            logging.warning("Error producing regex substitution %r for text = %r.\n\nError msg = %s", source_course_id, text, str(exc))

    return text
开发者ID:1amongus,项目名称:edx-platform,代码行数:50,代码来源:store_utilities.py

示例9: course_info_handler

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def course_info_handler(request, course_key_string):
    """
    GET
        html: return html for editing the course info handouts and updates.
    """
    course_key = CourseKey.from_string(course_key_string)
    course_module = _get_course_module(course_key, request.user)
    if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):

        return render_to_response(
            'course_info.html',
            {
                'context_course': course_module,
                'updates_url': reverse_course_url('course_info_update_handler', course_key),
                'handouts_locator': course_key.make_usage_key('course_info', 'handouts'),
                'base_asset_url': StaticContent.get_base_url_path_for_course_assets(course_module.id)
            }
        )
    else:
        return HttpResponseBadRequest("Only supports html requests")
开发者ID:87maxi,项目名称:edx-platform,代码行数:22,代码来源:course.py

示例10: course_info_handler

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def course_info_handler(request, course_key_string):
    """
    GET
        html: return html for editing the course info handouts and updates.
    """
    course_key = CourseKey.from_string(course_key_string)
    course_module = _get_course_module(course_key, request.user)
    if "text/html" in request.META.get("HTTP_ACCEPT", "text/html"):

        return render_to_response(
            "course_info.html",
            {
                "context_course": course_module,
                "updates_url": reverse_course_url("course_info_update_handler", course_key),
                "handouts_locator": course_key.make_usage_key("course_info", "handouts"),
                "base_asset_url": StaticContent.get_base_url_path_for_course_assets(course_module.id),
            },
        )
    else:
        return HttpResponseBadRequest("Only supports html requests")
开发者ID:hmcmooc,项目名称:muddx-platform,代码行数:22,代码来源:course.py

示例11: course_info

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def course_info(request, org, course, name, provided_id=None):
    """
    Send models and views as well as html for editing the course info to the
    client.

    org, course, name: Attributes of the Location for the item to edit
    """
    location = get_location_and_verify_access(request, org, course, name)

    course_module = modulestore().get_item(location)

    # get current updates
    location = Location(['i4x', org, course, 'course_info', "updates"])

    return render_to_response('course_info.html', {
        'context_course': course_module,
        'url_base': "/" + org + "/" + course + "/",
        'course_updates': json.dumps(get_course_updates(location)),
        'handouts_location': Location(['i4x', org, course, 'course_info', 'handouts']).url(),
        'base_asset_url': StaticContent.get_base_url_path_for_course_assets(location) + '/'})
开发者ID:finneysj,项目名称:edx-platform,代码行数:22,代码来源:course.py

示例12: get_html

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
    def get_html(self):
        if isinstance(modulestore(), MongoModuleStore):
            caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location) + '/subs_'
        else:
            # VS[compat]
            # cdodge: filesystem static content support.
            caption_asset_path = "/static/subs/"

        return self.system.render_template('videoalpha.html', {
            'youtube_streams': self.youtube_streams,
            'id': self.location.html_id(),
            'sub': self.sub,
            'sources': self.sources,
            'track': self.track,
            'display_name': self.display_name_with_default,
            # TODO (cpennington): This won't work when we move to data that isn't on the filesystem
            'data_dir': getattr(self, 'data_dir', None),
            'caption_asset_path': caption_asset_path,
            'show_captions': self.show_captions,
            'start': self.start_time,
            'end': self.end_time
        })
开发者ID:2bj,项目名称:edx-platform,代码行数:24,代码来源:videoalpha_module.py

示例13: rewrite_nonportable_content_links

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
    """
    Does a regex replace on non-portable links:
         /c4x/<org>/<course>/asset/<name> -> /static/<name>
         /jump_to/i4x://<org>/<course>/<category>/<name> -> /jump_to_id/<id>

    """

    org, course, run = source_course_id.split("/")
    dest_org, dest_course, dest_run = dest_course_id.split("/")

    def portable_asset_link_subtitution(match):
        quote = match.group('quote')
        rest = match.group('rest')
        return quote + '/static/' + rest + quote

    def portable_jump_to_link_substitution(match):
        quote = match.group('quote')
        rest = match.group('rest')
        return quote + '/jump_to_id/' + rest + quote

    def generic_courseware_link_substitution(match):
        quote = match.group('quote')
        rest = match.group('rest')
        dest_generic_courseware_lik_base = '/courses/{org}/{course}/{run}/'.format(
            org=dest_org, course=dest_course, run=dest_run
        )
        return quote + dest_generic_courseware_lik_base + rest + quote

    course_location = Location(['i4x', org, course, 'course', run])

    # NOTE: ultimately link updating is not a hard requirement, so if something blows up with
    # the regex subsitution, log the error and continue
    try:
        c4x_link_base = '{0}/'.format(StaticContent.get_base_url_path_for_course_assets(course_location))
        text = re.sub(_prefix_only_url_replace_regex(c4x_link_base), portable_asset_link_subtitution, text)
    except Exception, e:
        logging.warning("Error going regex subtituion %r on text = %r.\n\nError msg = %s", c4x_link_base, text, str(e))
开发者ID:Cabris,项目名称:edx-platform,代码行数:40,代码来源:store_utilities.py

示例14: studio_view

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
    def studio_view(self, context):
        """
        it will loads studio view
        :param context: context
        :return: fragment
        """
        block_id = "xblock-{}".format(self.get_block_id())
        course_key = getattr(self.scope_ids.usage_id, 'course_key', None)

        context['self'] = self
        context['block_id'] = block_id

        try:
            from xmodule.contentstore.content import StaticContent
            base_asset_url = StaticContent.get_base_url_path_for_course_assets(course_key)
        except:
            base_asset_url = ''

        return self.get_fragment(
            context,
            'studio',
            {
                'base_asset_url': base_asset_url,
                'quiz_type': self.quiz_type,
                'block_id': block_id,
                'results': self.results,
                'BUZZFEED_QUIZ_VALUE': self.BUZZFEED_QUIZ_VALUE,
                'DIAGNOSTIC_QUIZ_VALUE': self.DIAGNOSTIC_QUIZ_VALUE,
                'DEFAULT_GROUP': self.DEFAULT_GROUP,
                'questions': self.questions,
                'groups': self.groups,
                'attachedGroups': self.get_attached_groups(),
                'categoryTpl': loader.load_unicode('templates/underscore/category.html'),
                'rangeTpl': loader.load_unicode('templates/underscore/range.html'),
                'questionTpl': loader.load_unicode('templates/underscore/question.html'),
                'choiceTpl': loader.load_unicode('templates/underscore/choice.html')
            }
        )
开发者ID:mckinseyacademy,项目名称:xblock-diagnosticfeedback,代码行数:40,代码来源:quiz.py

示例15: rewrite_nonportable_content_links

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_base_url_path_for_course_assets [as 别名]
def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
    """
    Does a regex replace on non-portable links:
         /c4x/<org>/<course>/asset/<name> -> /static/<name>
         /jump_to/i4x://<org>/<course>/<category>/<name> -> /jump_to_id/<id>

    """

    course_id_dict = Location.parse_course_id(source_course_id)
    course_id_dict["tag"] = "i4x"
    course_id_dict["category"] = "course"

    def portable_asset_link_subtitution(match):
        quote = match.group("quote")
        rest = match.group("rest")
        return quote + "/static/" + rest + quote

    def portable_jump_to_link_substitution(match):
        quote = match.group("quote")
        rest = match.group("rest")
        return quote + "/jump_to_id/" + rest + quote

    def generic_courseware_link_substitution(match):
        parts = Location.parse_course_id(dest_course_id)
        parts["quote"] = match.group("quote")
        parts["rest"] = match.group("rest")
        return u"{quote}/courses/{org}/{course}/{name}/{rest}{quote}".format(**parts)

    course_location = Location(course_id_dict)

    # NOTE: ultimately link updating is not a hard requirement, so if something blows up with
    # the regex subsitution, log the error and continue
    try:
        c4x_link_base = u"{0}/".format(StaticContent.get_base_url_path_for_course_assets(course_location))
        text = re.sub(_prefix_only_url_replace_regex(c4x_link_base), portable_asset_link_subtitution, text)
    except Exception, e:
        logging.warning("Error going regex subtituion %r on text = %r.\n\nError msg = %s", c4x_link_base, text, str(e))
开发者ID:Neodemia,项目名称:edx-platform,代码行数:39,代码来源:store_utilities.py


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