PLAT-1884 Replace deprecated xblock.fragment usage

This commit is contained in:
Jeremy Bowman
2018-01-11 11:46:24 -05:00
parent 9dcedaf82b
commit f8e5e38cc4
32 changed files with 45 additions and 45 deletions

View File

@@ -11,8 +11,8 @@ from pkg_resources import resource_string
from six import text_type
from opaque_keys.edx.locator import BlockUsageLocator
from web_fragments.fragment import Fragment
from xblock.fields import ReferenceList, Scope, String
from xblock.fragment import Fragment
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.seq_module import SequenceDescriptor

View File

@@ -11,9 +11,9 @@ from fs.errors import ResourceNotFound
from lxml import etree
from path import Path as path
from pkg_resources import resource_string
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Boolean, List, Scope, String
from xblock.fragment import Fragment
import dogstats_wrapper as dog_stats_api
from xmodule.contentstore.content import StaticContent

View File

@@ -5,8 +5,8 @@ import textwrap
from lxml import etree
from pkg_resources import resource_string
from web_fragments.fragment import Fragment
from xblock.core import Scope, String
from xblock.fragment import Fragment
from xmodule.annotator_mixin import get_instructions, html_to_text
from xmodule.annotator_token import retrieve_token

View File

@@ -14,10 +14,10 @@ from lxml import etree
from opaque_keys.edx.locator import LibraryLocator
from pkg_resources import resource_string
from six import text_type
from web_fragments.fragment import Fragment
from webob import Response
from xblock.core import XBlock
from xblock.fields import Integer, List, Scope, String
from xblock.fragment import Fragment
from capa.responsetypes import registry
from xmodule.studio_editable import StudioEditableDescriptor, StudioEditableModule
@@ -325,7 +325,7 @@ class LibraryContentModule(LibraryContentFields, XModule, StudioEditableModule):
for child in self._get_selected_child_blocks():
for displayable in child.displayable_items():
rendered_child = displayable.render(STUDENT_VIEW, child_context)
fragment.add_frag_resources(rendered_child)
fragment.add_fragment_resources(rendered_child)
contents.append({
'id': text_type(displayable.location),
'content': rendered_child.content,

View File

@@ -3,9 +3,9 @@
"""
import logging
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Boolean, List, Scope, String
from xblock.fragment import Fragment
from xmodule.studio_editable import StudioEditableModule
@@ -97,7 +97,7 @@ class LibraryRoot(XBlock):
rendered_child = self.runtime.render_child(child, child_view_name, child_context)
else:
rendered_child = self.runtime.render_child_placeholder(child, child_view_name, child_context)
fragment.add_frag_resources(rendered_child)
fragment.add_fragment_resources(rendered_child)
contents.append({
'id': unicode(child.location),

View File

@@ -1,7 +1,7 @@
"""
Code to handle mako templating for XModules and XBlocks.
"""
from xblock.fragment import Fragment
from web_fragments.fragment import Fragment
from .x_module import DescriptorSystem, XModuleDescriptor, shim_xmodule_js

View File

@@ -1,9 +1,9 @@
"""
Tests for Asides
"""
from web_fragments.fragment import Fragment
from xblock.core import XBlockAside
from xblock.fields import Scope, String
from xblock.fragment import Fragment
from unittest import TestCase
from xmodule.modulestore.tests.utils import XmlModulestoreBuilder
from mock import patch

View File

@@ -22,6 +22,7 @@ import pymongo
from pytz import UTC
from shutil import rmtree
from tempfile import mkdtemp
from web_fragments.fragment import Fragment
from xmodule.x_module import XModuleMixin
from xmodule.modulestore.edit_info import EditInfoMixin
@@ -33,7 +34,6 @@ from xmodule.modulestore.xml_exporter import export_course_to_xml
from xmodule.modulestore.tests.test_asides import AsideTestType
from xblock.core import XBlockAside
from xblock.fields import Scope, String, ScopeIds
from xblock.fragment import Fragment
from xblock.runtime import DictKeyValueStore, KvsFieldData
from xblock.test.tools import TestRuntime

View File

@@ -2,8 +2,8 @@ import logging
import random
from lxml import etree
from web_fragments.fragment import Fragment
from xblock.fields import Integer, Scope
from xblock.fragment import Fragment
from xmodule.seq_module import SequenceDescriptor
from xmodule.x_module import STUDENT_VIEW, XModule

View File

@@ -12,10 +12,10 @@ from lxml import etree
from pkg_resources import resource_string
from pytz import UTC
from six import text_type
from web_fragments.fragment import Fragment
from xblock.completable import XBlockCompletionMode
from xblock.core import XBlock
from xblock.fields import Boolean, Integer, List, Scope, String
from xblock.fragment import Fragment
from .exceptions import NotFoundError
from .fields import Date
@@ -386,7 +386,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
context['bookmarked'] = is_bookmarked
rendered_item = item.render(STUDENT_VIEW, context)
fragment.add_frag_resources(rendered_item)
fragment.add_fragment_resources(rendered_item)
iteminfo = {
'content': rendered_item.content,

View File

@@ -18,9 +18,9 @@ from xmodule.modulestore.inheritance import UserPartitionList
from lxml import etree
from six import text_type
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Scope, Integer, String, ReferenceValueDict
from xblock.fragment import Fragment
log = logging.getLogger('edx.' + __name__)
@@ -218,7 +218,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule):
child_descriptor = self.get_child_descriptor_by_location(child_location)
child = self.system.get_module(child_descriptor)
rendered_child = child.render(STUDENT_VIEW, context)
fragment.add_frag_resources(rendered_child)
fragment.add_fragment_resources(rendered_child)
group_name, updated_group_id = self.get_data_for_vertical(child)
if updated_group_id is None: # inactive group
@@ -300,7 +300,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule):
DEFAULT_GROUP_NAME.format(group_id=group_id),
group_name
)
fragment.add_frag_resources(rendered_child)
fragment.add_fragment_resources(rendered_child)
html = html + rendered_child.content
return html
@@ -322,7 +322,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule):
'child_content': child_fragment.content,
'child_id': self.child.scope_ids.usage_id,
}))
fragment.add_frag_resources(child_fragment)
fragment.add_fragment_resources(child_fragment)
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/split_test_student.js'))
fragment.initialize_js('SplitTestStudentView')
return fragment

View File

@@ -24,7 +24,7 @@ class StudioEditableBlock(object):
context['reorderable_items'].add(child.location)
context['can_add'] = can_add
rendered_child = child.render(StudioEditableModule.get_preview_view_name(child), context)
fragment.add_frag_resources(rendered_child)
fragment.add_fragment_resources(rendered_child)
contents.append({
'id': unicode(child.location),

View File

@@ -7,7 +7,7 @@ Higher-level tests are in `cms/djangoapps/contentstore/tests/test_libraries.py`.
from bson.objectid import ObjectId
from mock import Mock, patch
from xblock.fragment import Fragment
from web_fragments.fragment import Fragment
from xblock.runtime import Runtime as VanillaRuntime
from xmodule.library_content_module import ANY_CAPA_TYPE_VALUE, LibraryContentDescriptor

View File

@@ -4,7 +4,7 @@ Basic unit tests for LibraryRoot
"""
from mock import patch
from xblock.fragment import Fragment
from web_fragments.fragment import Fragment
from xblock.runtime import Runtime as VanillaRuntime
from xmodule.x_module import AUTHOR_VIEW

View File

@@ -3,8 +3,8 @@ import textwrap
from lxml import etree
from pkg_resources import resource_string
from web_fragments.fragment import Fragment
from xblock.core import Scope, String
from xblock.fragment import Fragment
from xmodule.annotator_mixin import get_instructions
from xmodule.annotator_token import retrieve_token

View File

@@ -10,10 +10,10 @@ import logging
from lxml import etree
from opaque_keys.edx.keys import UsageKey
import six
from web_fragments.fragment import Fragment
from xblock.completable import XBlockCompletionMode
from xblock.core import XBlock
from xblock.exceptions import JsonHandlerError
from xblock.fragment import Fragment
from xmodule.mako_module import MakoTemplateBlockBase
@@ -106,7 +106,7 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
# pylint: disable=no-member
for child in self.get_display_items():
rendered_child = child.render(STUDENT_VIEW, child_context)
fragment.add_frag_resources(rendered_child)
fragment.add_fragment_resources(rendered_child)
contents.append({
'id': six.text_type(child.location),

View File

@@ -5,8 +5,8 @@ import textwrap
from lxml import etree
from pkg_resources import resource_string
from web_fragments.fragment import Fragment
from xblock.core import Scope, String
from xblock.fragment import Fragment
from xmodule.annotator_mixin import get_extension, get_instructions
from xmodule.annotator_token import retrieve_token

View File

@@ -10,8 +10,8 @@ import json
import logging
from pkg_resources import resource_string
from web_fragments.fragment import Fragment
from xblock.fields import Boolean, Dict, Integer, List, Scope, String
from xblock.fragment import Fragment
from xmodule.editing_module import MetadataOnlyEditingDescriptor
from xmodule.raw_module import EmptyDataRawDescriptor

View File

@@ -14,6 +14,7 @@ from pkg_resources import (
resource_string,
resource_isdir,
)
from web_fragments.fragment import Fragment
from webob import Response
from webob.multidict import MultiDict
from lazy import lazy
@@ -25,7 +26,6 @@ from xblock.fields import (
ReferenceValueDict, UserScope
)
from xblock.fragment import Fragment
from xblock.runtime import Runtime, IdReader, IdGenerator
from xmodule import block_metadata_utils
from xmodule.fields import RelativeTime
@@ -249,7 +249,7 @@ class HTMLSnippet(object):
def shim_xmodule_js(block, fragment):
"""
Set up the XBlock -> XModule shim on the supplied :class:`xblock.fragment.Fragment`
Set up the XBlock -> XModule shim on the supplied :class:`web_fragments.fragment.Fragment`
"""
if not fragment.js_init_fn:
fragment.initialize_js('XBlockToXModuleShim')