Skip to content

Commit

Permalink
feat: add get_taxonomy_by_export_id method
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Feb 21, 2024
1 parent 245a989 commit 7222b55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions openedx_tagging/core/tagging/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ def get_taxonomy(taxonomy_id: int) -> Taxonomy | None:
return taxonomy.cast() if taxonomy else None


def get_taxonomy_by_export_id(taxonomy_export_id: str) -> Taxonomy | None:
"""
Returns a Taxonomy cast to the appropriate subclass which has the given export ID.
"""
taxonomy = Taxonomy.objects.filter(export_id=taxonomy_export_id).first()
return taxonomy.cast() if taxonomy else None


def get_taxonomies(enabled=True) -> QuerySet[Taxonomy]:
"""
Returns a queryset containing the enabled taxonomies, sorted by name.
Expand Down
2 changes: 1 addition & 1 deletion openedx_tagging/core/tagging/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Taxonomy(models.Model):
"Indicates whether this taxonomy should be visible to object authors."
),
)
# External ID that should only be used on import/export.
# Export ID that should only be used on import/export.
# NOT use for any other purposes, you can use the numeric ID of the model instead;
# this id is editable.
export_id = models.CharField(
Expand Down

0 comments on commit 7222b55

Please sign in to comment.