-
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 data_fixtures migration to update channel headings
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
data_fixtures/migrations/0005_update_parent_topic_channel_descriptions.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,66 @@ | ||
# Generated by Django 4.2.14 on 2024-07-29 19:06 | ||
|
||
from django.db import migrations | ||
|
||
from channels.constants import ChannelType | ||
|
||
CHANNEL_UPDATES = { | ||
"Art, Design & Architecture": "Develop the creative, critical thinking, " | ||
"and problem-solving skills to shape our visual and spatial environment.", | ||
"Business & Management": "Build your leadership capabilities and position " | ||
"your organization to ensure a winning strategy and future growth.", | ||
"Data Science, Analytics & Computer Technology": "Gain the tools to " | ||
"surface insights from business data, make informed decisions, and apply " | ||
"the latest technology to advance your organization.", | ||
"Education & Teaching": "Improve educational systems, facilitate " | ||
"learning, and foster academic and personal growth for future " | ||
"generations.", | ||
"Social Sciences": "Build the context and tools to address social issues, " | ||
"inform public policy, and improve community and organizational " | ||
"practices.", | ||
"Science & Math": "Develop the critical-thinking skills to solve complex " | ||
"problems, drive scientific advancement, and apply findings in practical " | ||
"and impactful ways.", | ||
"Energy, Climate & Sustainability": "Develop and implement solutions to " | ||
"address environmental challenges, promote sustainable practices, and " | ||
"secure a better future for the planet.", | ||
"Engineering": "Apply the latest innovations in engineering to find " | ||
"innovative solutions for improving efficiency, safety, and quality of " | ||
"life.", | ||
"Humanities": "Enrich your understanding of the human condition, foster " | ||
"cultural appreciation, and contribute to the intellectual and ethical " | ||
"development of society.", | ||
"Innovation & Entrepreneurship": "Gain the tools and mindset needed " | ||
"to successfully launch and grow new ventures, drive innovation within " | ||
"existing organizations, and adapt to changing market conditions.", | ||
"Health & Medicine": "Improve individual and community health, advance " | ||
"medical science, and enhance the effectiveness and efficiency of health " | ||
"care systems.", | ||
} | ||
|
||
|
||
def update_parent_topic_channel_descriptions(apps, schema_editor): | ||
Channel = apps.get_model("channels", "Channel") | ||
LearningResourceTopic = apps.get_model( | ||
"learning_resources", "LearningResourceTopic" | ||
) | ||
|
||
for parent_topic in LearningResourceTopic.objects.filter(parent=None): | ||
channel = Channel.objects.filter( | ||
channel_type=ChannelType.topic.name, title=parent_topic.name | ||
).first() | ||
if channel: | ||
channel.configuration["heading"] = CHANNEL_UPDATES[parent_topic.name] | ||
channel.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("data_fixtures", "0004_upsert_initial_topic_data"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
update_parent_topic_channel_descriptions, migrations.RunPython.noop | ||
), | ||
] |