Skip to content

Commit

Permalink
feat: add delete_object_tags function to oel_tagging api (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido authored Aug 18, 2023
1 parent a1db0fe commit 79c16a0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openedx_learning/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.4"
13 changes: 13 additions & 0 deletions openedx_tagging/core/tagging/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ def get_object_tags(
yield object_tag


def delete_object_tags(object_id: str):
"""
Delete all ObjectTag entries for a given object.
"""
tags = (
ObjectTag.objects.filter(
object_id=object_id,
)
)

tags.delete()


def tag_object(
taxonomy: Taxonomy,
tags: List,
Expand Down
15 changes: 15 additions & 0 deletions tests/openedx_tagging/core/tagging/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,21 @@ def test_tag_object(self):
assert object_tag.name == self.taxonomy.name
assert object_tag.object_id == "biology101"

# Delete the tags
tagging_api.delete_object_tags("biology101")

# Ensure the tags were deleted
assert (
len(
list(
tagging_api.get_object_tags(
object_id="biology101",
)
)
)
== 0
)

def test_tag_object_free_text(self):
self.taxonomy.allow_free_text = True
self.taxonomy.save()
Expand Down

0 comments on commit 79c16a0

Please sign in to comment.