Skip to content

Commit

Permalink
add data_fixtures migration to update channel headings
Browse files Browse the repository at this point in the history
  • Loading branch information
gumaerc committed Jul 29, 2024
1 parent c2d2737 commit 37e6d74
Showing 1 changed file with 66 additions and 0 deletions.
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
),
]

0 comments on commit 37e6d74

Please sign in to comment.