-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration to adjust mappings, make some minor changes to the dump…
… to yaml util function (#1408) dump_topic_to_yaml now will include the parent ID if there is one, and fixes a bug where dumping a single topic failed
- Loading branch information
Showing
2 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...fixtures/migrations/0012_topic_mappings_adjust_sustainable_business_finance_accounting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
""" | ||
Update the topics: | ||
- Add mapping "Sustainability" to "Sustainable Business" for mitxpro, mitpe, see | ||
- Add mapping "Economics & Finance" to "Finance & Accounting" for mitx | ||
""" | ||
|
||
from django.db import migrations | ||
|
||
from learning_resources.utils import upsert_topic_data_string | ||
|
||
forward_map_changes = """ | ||
--- | ||
topics: | ||
- children: [] | ||
icon: RiLightbulbFlashLine | ||
id: d18ae735-9eb0-42ec-982d-798590f78b68 | ||
mappings: | ||
mitxpro: | ||
- Sustainability | ||
mitpe: | ||
- Sustainability | ||
see: | ||
- Sustainability | ||
name: Sustainable Business | ||
parent: 58eeca97-031c-432f-89f5-5b6493bf0dd2 | ||
- children: [] | ||
icon: RiBriefcase3Line | ||
id: b84810f6-b232-4443-9471-eff7823a5f93 | ||
mappings: | ||
mitpe: | ||
- Finance | ||
ocw: | ||
- Accounting | ||
- Finance | ||
see: | ||
- Finance | ||
xpro: | ||
- Finance | ||
mitx: | ||
- Economics & Finance | ||
name: Finance & Accounting | ||
parent: 99ec5b40-e929-4ad9-bccf-7305ef6938b1 | ||
""" | ||
|
||
reverse_map_changes = """ | ||
--- | ||
topics: | ||
- children: [] | ||
icon: RiLightbulbFlashLine | ||
id: d18ae735-9eb0-42ec-982d-798590f78b68 | ||
mappings: {} | ||
name: Sustainable Business | ||
parent: 58eeca97-031c-432f-89f5-5b6493bf0dd2 | ||
- children: [] | ||
icon: RiBriefcase3Line | ||
id: b84810f6-b232-4443-9471-eff7823a5f93 | ||
mappings: | ||
mitpe: | ||
- Finance | ||
ocw: | ||
- Accounting | ||
- Finance | ||
see: | ||
- Finance | ||
xpro: | ||
- Finance | ||
name: Finance & Accounting | ||
parent: 99ec5b40-e929-4ad9-bccf-7305ef6938b1 | ||
""" | ||
|
||
|
||
def add_new_mapping(apps, schema_editor): | ||
"""Upsert the forward_map_changes data above.""" | ||
|
||
upsert_topic_data_string(forward_map_changes) | ||
|
||
|
||
def rollback_new_mapping(apps, schema_editor): | ||
"""Upsert the reverse_map_changes data above.""" | ||
|
||
upsert_topic_data_string(reverse_map_changes) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("data_fixtures", "0011_unit_page_copy_updates"), | ||
] | ||
|
||
operations = [migrations.RunPython(add_new_mapping, rollback_new_mapping)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters