-
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.
adding migrations for copy update (#1276)
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
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,95 @@ | ||
# Generated by Django 4.2.14 on 2024-07-16 17:30 | ||
|
||
from django.db import migrations | ||
|
||
fixtures = [ | ||
{ | ||
"name": "mitpe", | ||
"offeror_configuration": { | ||
"value_prop": ( | ||
"MIT Professional Education is a leader in technology and " | ||
"engineering education for working professionals pursuing " | ||
"career advancement, and organizations seeking to meet modern-day " | ||
"challenges by expanding the knowledge and skills of their employees. " | ||
"Courses are delivered in a range of formats—in-person (on-campus " | ||
"and live virtual), online, and through hybrid approaches—to " | ||
"meet the needs of today's learners." | ||
), | ||
}, | ||
"channel_configuration": { | ||
"sub_heading": ( | ||
"MIT Professional Education is a leader in technology and " | ||
"engineering education for working professionals pursuing " | ||
"career advancement, and organizations seeking to meet modern-day " | ||
"challenges by expanding the knowledge and skills of their employees. " | ||
"Courses are delivered in a range of formats—in-person (on-campus " | ||
"and live virtual), online, and through hybrid approaches—to " | ||
"meet the needs of today's learners." | ||
), | ||
}, | ||
}, | ||
{ | ||
"name": "ocw", | ||
"offeror_configuration": { | ||
"value_prop": ( | ||
"For millions of learners and educators around the world, " | ||
"OpenCourseWare shares free open educational resources from " | ||
"across the entire MIT curriculum. With no sign-up needed, " | ||
"thousands of downloadable materials, and convenient online access, " | ||
"you're empowered for self-paced learning and adapting these " | ||
"materials in the ways that suit you best." | ||
), | ||
}, | ||
"channel_configuration": { | ||
"heading": ( | ||
"Free open online resources from over 2,500 MIT " | ||
"courses for self-paced learning and classroom teaching." | ||
), | ||
"sub_heading": ( | ||
"For millions of learners and educators around the world, " | ||
"OpenCourseWare shares free open educational resources from " | ||
"across the entire MIT curriculum. With no sign-up needed, " | ||
"thousands of downloadable materials, and convenient online access, " | ||
"you're empowered for self-paced learning and adapting these " | ||
"materials in the ways that suit you best." | ||
), | ||
}, | ||
}, | ||
{ | ||
"name": "xpro", | ||
"offeror_configuration": { | ||
"formats": ["Online", "In-Person", "Hybrid"], | ||
}, | ||
"channel_configuration": {}, | ||
}, | ||
] | ||
|
||
|
||
def update_copy(apps, schema_editor): | ||
Channel = apps.get_model("channels", "Channel") | ||
LearningResourceOfferor = apps.get_model( | ||
"learning_resources", "LearningResourceOfferor" | ||
) | ||
for fixture in fixtures: | ||
channel_configuration_updates = fixture["channel_configuration"] | ||
offeror_configuration_updates = fixture["offeror_configuration"] | ||
channel = Channel.objects.get(name=fixture["name"]) | ||
if Channel.objects.filter(name=fixture["name"]).exists(): | ||
for key, val in channel_configuration_updates.items(): | ||
channel.configuration[key] = val | ||
channel.save() | ||
if LearningResourceOfferor.objects.filter(code=fixture["name"]).exists(): | ||
offeror = LearningResourceOfferor.objects.get(code=fixture["name"]) | ||
for key, val in offeror_configuration_updates.items(): | ||
setattr(offeror, key, val) | ||
offeror.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("data_fixtures", "0002_unit_page_copy_updates"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_copy, migrations.RunPython.noop), | ||
] |