feat: duplicate tags when duplicating a tagged XBlock. #637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Updates the TaggedBlockMixin to add a
studio_post_duplicate
handler which copies the tags on thesource_item
to the duplicated block.More information
Closes openedx/modular-learning#181
Depends on
Private ref: FAL-3623
Testing instructions
Author Notes & Concerns
The implementation plan sketched out in openedx/modular-learning#181 has a flaw: When I tried storing the tag data in
duplicate_metadata
, eventuallymodulestore.create_item
calls partition_fields_by_scope, which tries to callfield = getattr(cls, 'tags-v1')
. This errors out becausetags-v1
isn't a real XBlock field.We could fix this by refactoring TaggedBlockMixin to use a proper XBlock field for the tag data (and since we can't have a class attribute with a hyphen in it, we'd need to rename the field from
tags-v1
totags_v1
).Instead, I chose to use the XBlock
studio_post_duplicate
handler, as shown. A disadvantage of this approach is there's no good way to disable duplicating content tags when duplicating an XBlock; content tags will always be duplicated too.