Skip to content

Commit

Permalink
fix: overwrite previous tags on import (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido authored Nov 21, 2023
1 parent 75b335d commit 3ae1c01
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion openedx_learning/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Open edX Learning ("Learning Core").
"""
__version__ = "0.3.4"
__version__ = "0.3.5"
5 changes: 3 additions & 2 deletions openedx_tagging/core/tagging/rest_api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ def create_import(self, request: Request, **_kwargs) -> Response:
@action(detail=True, url_path="tags/import", methods=["put"])
def update_import(self, request: Request, **_kwargs) -> Response:
"""
Imports tags from the uploaded file to an already created taxonomy.
Imports tags from the uploaded file to an already created taxonomy,
overwriting any existing tags.
"""
body = TaxonomyImportBodySerializer(data=request.data)
body.is_valid(raise_exception=True)
Expand All @@ -304,7 +305,7 @@ def update_import(self, request: Request, **_kwargs) -> Response:

taxonomy = self.get_object()
try:
import_success = import_tags(taxonomy, file, parser_format)
import_success = import_tags(taxonomy, file, parser_format, replace=True)

if import_success:
serializer = self.get_serializer(taxonomy)
Expand Down
5 changes: 2 additions & 3 deletions tests/openedx_tagging/core/tagging/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2230,10 +2230,9 @@ def test_import(self, file_format: str) -> None:
url = TAXONOMY_TAGS_URL.format(pk=self.taxonomy.id)
response = self.client.get(url)
tags = response.data["results"]
all_tags = [{"value": tag.value} for tag in self.old_tags] + new_tags
assert len(tags) == len(all_tags)
assert len(tags) == len(new_tags)
for i, tag in enumerate(tags):
assert tag["value"] == all_tags[i]["value"]
assert tag["value"] == new_tags[i]["value"]

def test_import_no_file(self) -> None:
"""
Expand Down

0 comments on commit 3ae1c01

Please sign in to comment.