Beispiel #1
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The unit page will remain as is for now.
    if context.get('container_view', None) and view == 'student_view':
        root_xblock = context.get('root_xblock')
        is_root = root_xblock and xblock.location == root_xblock.location
        locator = loc_mapper().translate_location(xblock.course_id, xblock.location, published=False)
        is_reorderable = _is_xblock_reorderable(xblock, context)
        template_context = {
            'xblock_context': context,
            'xblock': xblock,
            'locator': locator,
            'content': frag.content,
            'is_root': is_root,
            'is_reorderable': is_reorderable,
        }
        # For child xblocks with their own page, render a link to the page
        if xblock_has_own_studio_page(xblock) and not is_root:
            template = 'studio_container_wrapper.html'
        else:
            template = 'studio_xblock_wrapper.html'
        html = render_to_string(template, template_context)
        frag = wrap_fragment(frag, html)
    return frag
Beispiel #2
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The unit page will remain as is for now.
    if context.get('container_view', None) and view == 'student_view':
        locator = loc_mapper().translate_location(xblock.course_id,
                                                  xblock.location,
                                                  published=False)
        template_context = {
            'xblock_context': context,
            'xblock': xblock,
            'locator': locator,
            'content': frag.content,
        }
        if xblock.category == 'vertical':
            template = 'studio_vertical_wrapper.html'
        elif xblock.location != context.get(
                'root_xblock').location and xblock.has_children:
            template = 'container_xblock_component.html'
        else:
            template = 'studio_xblock_wrapper.html'
        html = render_to_string(template, template_context)
        frag = wrap_fragment(frag, html)
    return frag
Beispiel #3
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The "Pages" page will remain as is for now.
    if not context.get('is_pages_view', None) and view in PREVIEW_VIEWS:
        root_xblock = context.get('root_xblock')
        is_root = root_xblock and xblock.location == root_xblock.location
        is_reorderable = _is_xblock_reorderable(xblock, context)
        template_context = {
            'xblock_context': context,
            'xblock': xblock,
            'content': frag.content,
            'is_root': is_root,
            'is_reorderable': is_reorderable,
        }
        html = render_to_string('studio_xblock_wrapper.html', template_context)
        frag = wrap_fragment(frag, html)
    return frag
Beispiel #4
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The "Pages" page will remain as is for now.
    if not context.get('is_pages_view', None) and view in PREVIEW_VIEWS:
        root_xblock = context.get('root_xblock')
        is_root = root_xblock and xblock.location == root_xblock.location
        is_reorderable = _is_xblock_reorderable(xblock, context)
        template_context = {
            'xblock_context': context,
            'xblock': xblock,
            'content': frag.content,
            'is_root': is_root,
            'is_reorderable': is_reorderable,
        }
        html = render_to_string('studio_xblock_wrapper.html', template_context)
        frag = wrap_fragment(frag, html)
    return frag
Beispiel #5
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The unit page will remain as is for now.
    if context.get('container_view', None) and view == 'student_view':
        locator = loc_mapper().translate_location(xblock.course_id, xblock.location)
        template_context = {
            'xblock_context': context,
            'xblock': xblock,
            'locator': locator,
            'content': frag.content,
        }
        if xblock.category == 'vertical':
            template = 'studio_vertical_wrapper.html'
        else:
            template = 'studio_xblock_wrapper.html'
        html = render_to_string(template, template_context)
        frag = wrap_fragment(frag, html)
    return frag
Beispiel #6
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The "Pages" page will remain as is for now.
    if not context.get("is_pages_view", None) and view in PREVIEW_VIEWS:
        root_xblock = context.get("root_xblock")
        is_root = root_xblock and xblock.location == root_xblock.location
        is_reorderable = _is_xblock_reorderable(xblock, context)
        template_context = {
            "xblock_context": context,
            "xblock": xblock,
            "show_preview": context.get("show_preview", True),
            "content": frag.content,
            "is_root": is_root,
            "is_reorderable": is_reorderable,
            "can_edit": context.get("can_edit", True),
            "can_edit_visibility": context.get("can_edit_visibility", True),
            "can_add": context.get("can_add", True),
        }
        html = render_to_string("studio_xblock_wrapper.html", template_context)
        frag = wrap_fragment(frag, html)
    return frag
Beispiel #7
0
def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
    """
    Wraps the results of rendering an XBlock view in a div which adds a header and Studio action buttons.
    """
    # Only add the Studio wrapper when on the container page. The unit page will remain as is for now.
    if context.get('container_view', None) and view == 'student_view':
        root_xblock = context.get('root_xblock')
        is_root = root_xblock and xblock.location == root_xblock.location
        is_reorderable = _is_xblock_reorderable(xblock, context)
        template_context = {
            'xblock_context': context,
            'xblock': xblock,
            'content': frag.content,
            'is_root': is_root,
            'is_reorderable': is_reorderable,
        }
        # For child xblocks with their own page, render a link to the page
        if xblock_has_own_studio_page(xblock) and not is_root:
            template = 'studio_container_wrapper.html'
        else:
            template = 'studio_xblock_wrapper.html'
        html = render_to_string(template, template_context)
        frag = wrap_fragment(frag, html)
    return frag