Commit 33af47a7 by Calen Pennington

Merge pull request #11841 from CredoReference/copy_question_should_also_copy_tags

Duplicate item in Studio should also duplicate related xblock aside
parents 7600d9b0 8f1a4cca
......@@ -595,6 +595,18 @@ def _duplicate_item(parent_usage_key, duplicate_source_usage_key, user, display_
else:
duplicate_metadata['display_name'] = _("Duplicate of '{0}'").format(source_item.display_name)
asides_to_create = []
for aside in source_item.runtime.get_asides(source_item):
for field in aside.fields.values():
if field.scope in (Scope.settings, Scope.content,) and field.is_set_on(aside):
asides_to_create.append(aside)
break
for aside in asides_to_create:
for field in aside.fields.values():
if field.scope not in (Scope.settings, Scope.content,):
field.delete_from(aside)
dest_module = store.create_item(
user.id,
dest_usage_key.course_key,
......@@ -603,6 +615,7 @@ def _duplicate_item(parent_usage_key, duplicate_source_usage_key, user, display_
definition_data=source_item.get_explicitly_set_fields_by_scope(Scope.content),
metadata=duplicate_metadata,
runtime=source_item.runtime,
asides=asides_to_create
)
children_handled = False
......
......@@ -47,7 +47,7 @@ class SplitMongoKVS(InheritanceKeyValueStore):
def get(self, key):
if key.block_family == XBlockAside.entry_point:
if key.scope not in [Scope.settings, Scope.content]:
if key.scope not in self.VALID_SCOPES:
raise InvalidScopeError(key, self.VALID_SCOPES)
if key.block_scope_id.block_type not in self.aside_fields:
......@@ -139,6 +139,9 @@ class SplitMongoKVS(InheritanceKeyValueStore):
Is the given field explicitly set in this kvs (not inherited nor default)
"""
# handle any special cases
if key.scope not in self.VALID_SCOPES:
return False
if key.scope == Scope.content:
self._load_definition()
elif key.scope == Scope.parent:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment