-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Copy object tags [FC-0062] #236
feat: Copy object tags [FC-0062] #236
Conversation
Thanks for the pull request, @ChrisChV! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
…et the serializer for tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 @ChrisChV Perfect 💯
- I tested this: (Copied tags, deleted tags, added same tag in source and dest and copied them.)
- I read through the code
- I checked for accessibility issues
- Includes documentation
|
||
assert len(object_tags) == 2 | ||
for index, object_tag in enumerate(object_tags): | ||
object_tag.full_clean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object_tag.full_clean() |
Is full_clean
required here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested some changes. Thinking ahead, we may also need an API to "convert" the tags if/when the link is broken. That is, if the user links some library into a course, then later breaks the link, the tags that were read-only would need to be changed to is_copied=False
so that they can be edited. But we can do that in a separate PR if you prefer.
default=False, | ||
help_text=_( | ||
"True if this object tag has been copied from one object to another" | ||
" using 'copy_tags' api function" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" using 'copy_tags' api function" | |
" using 'copy_tags' api function. Used to make copied tags read-only in the UI." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should not be here. If the tagging app is reused in another project other than edx-platform, a copied tag does not necessarily mean it is read-only in the UI.
@@ -176,6 +176,7 @@ def to_representation(self, instance: list[ObjectTag]) -> dict: | |||
""" | |||
Convert this list of ObjectTags to the serialized dictionary, grouped by Taxonomy | |||
""" | |||
ObjectTagViewMinimalSerializer = self.context["view"].minimal_serilizer_class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this, vs. just hard-coding the use of ObjectTagMinimalSerializer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do it this way so that that serializer can be overridden. In my other PR I override that serializer to override get_can_delete_objecttag
and prevent the user from deleting copied tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to mention this in a comment: "# Allows consumers like edx-platform to override this"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated: 7289b22
openedx_tagging/core/tagging/api.py
Outdated
taxonomy_id=object_tag.taxonomy_id, | ||
tag_id=object_tag.tag_id, | ||
defaults={"is_copied": True}, | ||
# Note: _value and _export_id should be set automatically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you confirm this is working? (That _value
and _export_id
are getting set automatically?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment: 6395019
@ChrisChV I can merge this when you fix the conflicts and reply - let me know. |
@bradenmacdonald It's ready for merge.
Sorry I forgot this, yes, we can do this in a separate PR |
This PR adds:
copy_tags
inapi.py
to copy tags between objects.is_copied
inObjectTag
Supporting information
Testing instructions
Deadline
ASAP