From c9ffc225fc7f6e4f58dfcda81aaf8a6db8b02fd0 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Thu, 6 Feb 2025 17:47:26 +1030 Subject: [PATCH 1/2] feat: adds unmark_copied_tags method to tagging API --- openedx_tagging/core/tagging/api.py | 7 ++++++ .../core/fixtures/tagging.yaml | 2 +- .../openedx_tagging/core/tagging/test_api.py | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/openedx_tagging/core/tagging/api.py b/openedx_tagging/core/tagging/api.py index c72ce6da..8c03c740 100644 --- a/openedx_tagging/core/tagging/api.py +++ b/openedx_tagging/core/tagging/api.py @@ -516,3 +516,10 @@ def copy_tags(source_object_id: str, dest_object_id: str): defaults={"is_copied": True}, # Note: _value and _export_id are set automatically ) + + +def unmark_copied_tags(object_id: str) -> None: + """ + Update copied object tags on the given object to mark them as "not copied". + """ + ObjectTag.objects.filter(object_id=object_id).update(is_copied=False) diff --git a/tests/openedx_tagging/core/fixtures/tagging.yaml b/tests/openedx_tagging/core/fixtures/tagging.yaml index cd0204f3..8f070029 100644 --- a/tests/openedx_tagging/core/fixtures/tagging.yaml +++ b/tests/openedx_tagging/core/fixtures/tagging.yaml @@ -247,7 +247,7 @@ name: System defined taxonomy description: Generic System defined taxonomy enabled: true - allow_multiple: false + allow_multiple: true allow_free_text: false export_id: system_defined_taxonomy _taxonomy_class: openedx_tagging.core.tagging.models.system_defined.SystemDefinedTaxonomy diff --git a/tests/openedx_tagging/core/tagging/test_api.py b/tests/openedx_tagging/core/tagging/test_api.py index ce32295f..25f57d96 100644 --- a/tests/openedx_tagging/core/tagging/test_api.py +++ b/tests/openedx_tagging/core/tagging/test_api.py @@ -1046,3 +1046,27 @@ def test_copy_tags_with_non_copied(self) -> None: assert object_tag.taxonomy == expected_tags[index]["taxonomy"] assert object_tag.object_id == obj2 assert object_tag.is_copied == expected_tags[index]["copied"] + + def test_unmark_copied_tags(self) -> None: + obj1 = "object_id1" + obj2 = "object_id2" + + # Put 2 tags on obj1 + tagging_api.tag_object(object_id=obj1, taxonomy=self.language_taxonomy, tags=["English"]) + tagging_api.tag_object(object_id=obj1, taxonomy=self.system_taxonomy, tags=["System Tag 1"]) + + # Copy tags from obj1 to obj2 + tagging_api.copy_tags(obj1, obj2) + + # Update obj2's tags to include one non-copied tag + tagging_api.tag_object(object_id=obj2, taxonomy=self.system_taxonomy, tags=["System Tag 1", "System Tag 2"]) + + tags = tagging_api.get_object_tags(obj2) + assert tags.filter(is_copied=False).count() == 1 + assert tags.filter(is_copied=True).count() == 2 + + tagging_api.unmark_copied_tags(obj2) + + tags = tagging_api.get_object_tags(obj2) + assert tags.filter(is_copied=False).count() == 3 + assert tags.filter(is_copied=True).count() == 0 From 04d3a931a474fc2111f5e065721e3f64a0ac8d58 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Thu, 6 Feb 2025 17:52:33 +1030 Subject: [PATCH 2/2] chore: bumps package version --- openedx_learning/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx_learning/__init__.py b/openedx_learning/__init__.py index 8c8f8f0a..9f57f2a2 100644 --- a/openedx_learning/__init__.py +++ b/openedx_learning/__init__.py @@ -2,4 +2,4 @@ Open edX Learning ("Learning Core"). """ -__version__ = "0.18.2" +__version__ = "0.18.3"