Skip to content

Commit

Permalink
fix: Move resync from delete_tags to add_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh committed Oct 18, 2023
1 parent b2e5323 commit dd35747
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions openedx_tagging/core/tagging/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,16 @@ def add_tag_to_taxonomy(
Taxonomy, an exception is raised, otherwise the newly created
Tag is returned
"""
return taxonomy.cast().add_tag(tag, parent_tag_value, external_id)
taxonomy = taxonomy.cast()
new_tag = taxonomy.add_tag(tag, parent_tag_value, external_id)

# Resync all related ObjectTags after creating new Tag to
# to ensure any existing ObjectTags with the same value will
# be linked to the new Tag
object_tags = taxonomy.objecttag_set.all()
resync_object_tags(object_tags)

return new_tag


def update_tag_in_taxonomy(taxonomy: Taxonomy, tag: str, new_value: str):
Expand Down Expand Up @@ -361,7 +370,3 @@ def delete_tags_from_taxonomy(
"""
taxonomy = taxonomy.cast()
taxonomy.delete_tags(tags, with_subtags)

# Resync all related ObjectTags after deleting the Tag(s)
object_tags = taxonomy.objecttag_set.all()
resync_object_tags(object_tags)

0 comments on commit dd35747

Please sign in to comment.