feat: Paste Components (OLX) into any Unit in Studio (#31969)
* feat: Implement paste button * chore: improve docs and add tests for python API * fix: drive-by fix to use a better API for comparing XML * feat: track which XBlock something was copied from * feat: add tests * feat: enable import linter so content_staging's public API is respected * fix: error seen when trying to paste drag-and-drop-v2 blocks * fix: use strip_text=True consistently for XML comparisons * refactor: rename get_user_clipboard_status to get_user_clipboard * feat: Better error reporting when pasting in Studio * chore: convert new test suite to pytest assertions * refactor: push READY status check into the API per review suggestion * fix: use strip_text=True consistently for XML comparisons * fix: store "copied_from_block" as a string to avoid Reference field issues * fix: minor lint error * refactor: move data types to data.py per OEP-49
This commit is contained in:
@@ -1953,9 +1953,12 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
|
||||
the definition, structure, nor course if they didn't change.
|
||||
"""
|
||||
partitioned_fields = self.partition_xblock_fields_by_scope(block)
|
||||
definition_locator = getattr(block, "definition_locator", None)
|
||||
if definition_locator is None and not allow_not_found:
|
||||
raise AttributeError("block is missing expected definition_locator from caching descriptor system")
|
||||
return self._update_item_from_fields(
|
||||
user_id, block.location.course_key, BlockKey.from_usage_key(block.location),
|
||||
partitioned_fields, block.definition_locator, allow_not_found, force, **kwargs
|
||||
partitioned_fields, definition_locator, allow_not_found, force, **kwargs
|
||||
) or block
|
||||
|
||||
def _update_item_from_fields(self, user_id, course_key, block_key, partitioned_fields, # pylint: disable=too-many-statements
|
||||
@@ -2162,7 +2165,8 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
|
||||
partitioned_fields = self.partition_xblock_fields_by_scope(xblock)
|
||||
new_def_data = self._serialize_fields(xblock.category, partitioned_fields[Scope.content])
|
||||
is_updated = False
|
||||
if xblock.definition_locator is None or isinstance(xblock.definition_locator.definition_id, LocalId):
|
||||
current_definition_locator = getattr(xblock, "definition_locator", xblock.scope_ids.def_id)
|
||||
if current_definition_locator is None or isinstance(current_definition_locator.definition_id, LocalId):
|
||||
xblock.definition_locator = self.create_definition_from_data(
|
||||
course_key, new_def_data, xblock.category, user_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user