Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update create_taxonomy with the export_id #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def import_tarfile_in_course(tarfile_path, course_key, user_id):
IMPORT_WGU_TAXONOMY = True


def get_or_create_taxonomy(org_taxonomies, name, orgs, enabled=True, description="", old_name=None):
def get_or_create_taxonomy(
org_taxonomies, name, orgs, enabled=True, description="", old_name=None, export_id=None,
):
"""
Get or create Taxonomy for Sample Taxonomy Orgs

Expand Down Expand Up @@ -260,7 +262,21 @@ def get_or_create_taxonomy(org_taxonomies, name, orgs, enabled=True, description
# delete and start from scratch
Taxonomy.objects.filter(name=name, enabled=enabled).delete()

taxonomy = create_taxonomy(name=name, orgs=orgs, enabled=enabled, allow_multiple=True)
update_export_id = False
if not export_id:
export_id = name.lower().replace(' ', '_')
update_export_id = True
taxonomy = create_taxonomy(
name=name,
export_id=export_id,
orgs=orgs,
enabled=enabled,
allow_multiple=True,
)
if update_export_id:
# Update export_id with taxonomy id to avoid duplicates.
taxonomy.export_id = f"{taxonomy.id}_{export_id}"


if org_taxonomies is None:
set_taxonomy_orgs(taxonomy, all_orgs=True)
Expand Down