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

Enforce limit on number of tags per object #81

Conversation

rpenido
Copy link
Contributor

@rpenido rpenido commented Sep 19, 2023

Description

This PR enforces a 100 hardcoded limit on the number of ObjectTags applied on any object. It also removes the pagination of the tagging REST API for listing and updating object tags.

Supporting Information

Testing instructions

  • Please ensure that the tests cover the expected behavior of the view as described in the related issue.

After merge

  • Create a Tag with the version v0.1.7

Private-ref: FAL-3501

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 19, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 19, 2023

Thanks for the pull request, @rpenido! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@rpenido
Copy link
Contributor Author

rpenido commented Sep 19, 2023

ToDo: bump version

Copy link
Member

@yusuf-musleh yusuf-musleh left a comment

Choose a reason for hiding this comment

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

@rpenido Great work! I just had a few comments on a test case we are missing if you could take a look.


if current_count >= 100:
raise ValueError(
_(f"Object ({object_id}) already have 100 or more tags.")
Copy link
Member

Choose a reason for hiding this comment

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

nit: just a small spelling fix, "already have" -> "already has"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed here:

_(f"Cannot add more than 100 tags to ({object_id}).")

We are talking about the future state, not the current.

_(f"Object ({object_id}) already have 100 or more tags.")
)

_check_current_tag_count()
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this check also include the count of the new tags that will will be potentially be added, since this check is happening at the beginning of the function call? Eg: What happens when the current_count is say 99 but there are 2 new tags in the tags list leading to 101, would this check catch it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right @yusuf-musleh! I totally missed the allow_multiple cases.
Thank you for pointing out!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 432e4c2

@@ -782,3 +743,21 @@ def test_tag_object_without_permission(self, user_attr, expected_status):

response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
assert response.status_code == expected_status
assert not status.is_success(expected_status) # No success cases here

def test_tag_object_count_limit(self):
Copy link
Member

Choose a reason for hiding this comment

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

Would super helpful if we could also add a test case that covers the scenario described above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! Thank you!

Done here: 432e4c2

@rpenido rpenido marked this pull request as ready for review September 21, 2023 13:01
Copy link
Member

@yusuf-musleh yusuf-musleh left a comment

Choose a reason for hiding this comment

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

👍 Thanks for making the changes! Looks good to me, I believe @bradenmacdonald would need to do the final approval/merge for it.

  • I tested this: I read through the tests to make sure it covers the cases
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository.

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.

Nice work! And I love the simplification of not needing pagination due to the new rule.

@bradenmacdonald bradenmacdonald merged commit 681c1a0 into openedx:main Sep 25, 2023
6 checks passed
@openedx-webhooks
Copy link

@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@bradenmacdonald bradenmacdonald deleted the rpenido/fal-3501-enforce-limit-on-number-of-tags-per-object branch September 25, 2023 19:25
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
None yet
Development

Successfully merging this pull request may close these issues.

[Tagging] Enforce limit on number of tags per object
4 participants