Skip to content
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

Merged
merged 11 commits into from
Oct 16, 2024

Conversation

ChrisChV
Copy link
Contributor

@ChrisChV ChrisChV commented Oct 2, 2024

This PR adds:

  • A function copy_tags in api.py to copy tags between objects.
  • A new field is_copied in ObjectTag

Supporting information

Testing instructions

Deadline

ASAP

@openedx-webhooks
Copy link

openedx-webhooks commented Oct 2, 2024

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If 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 @axim-engineering. Tag them in a comment and let them know that your changes are ready for review.

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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 2, 2024
@ChrisChV ChrisChV marked this pull request as draft October 2, 2024 00:37
@ChrisChV ChrisChV changed the title feat: Copy tags function and read_only Object tags feat: Copy object tags Oct 8, 2024
@ChrisChV ChrisChV changed the title feat: Copy object tags feat: Copy object tags [FC-0062] Oct 8, 2024
@ChrisChV ChrisChV marked this pull request as ready for review October 8, 2024 21:19
Copy link
Contributor

@navinkarkera navinkarkera left a 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

openedx_tagging/core/tagging/api.py Outdated Show resolved Hide resolved
openedx_tagging/core/tagging/api.py Outdated Show resolved Hide resolved

assert len(object_tags) == 2
for index, object_tag in enumerate(object_tags):
object_tag.full_clean()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
object_tag.full_clean()

Is full_clean required here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we use full_clean() to validate the object tag in the test. It's used in other tests: [1][2][3]

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a 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.

openedx_tagging/core/tagging/rest_api/v1/views.py Outdated Show resolved Hide resolved
openedx_tagging/core/tagging/api.py Outdated Show resolved Hide resolved
openedx_tagging/core/tagging/api.py Outdated Show resolved Hide resolved
default=False,
help_text=_(
"True if this object tag has been copied from one object to another"
" using 'copy_tags' api function"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" using 'copy_tags' api function"
" using 'copy_tags' api function. Used to make copied tags read-only in the UI."

Copy link
Contributor Author

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
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor

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"

Copy link
Contributor Author

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 Show resolved Hide resolved
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
Copy link
Contributor

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?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I confirm that 👍

Captura desde 2024-10-15 19-40-19

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment: 6395019

@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Oct 15, 2024

@ChrisChV I can merge this when you fix the conflicts and reply - let me know.

@ChrisChV
Copy link
Contributor Author

@bradenmacdonald It's ready for merge.

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.

Sorry I forgot this, yes, we can do this in a separate PR

@bradenmacdonald bradenmacdonald merged commit cdb2e3d into openedx:main Oct 16, 2024
9 checks passed
@bradenmacdonald bradenmacdonald deleted the chris/FAL-3616-copy-tags branch October 16, 2024 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants