diff --git a/data_fixtures/migrations/0003_unit_page_copy_updates.py b/data_fixtures/migrations/0003_unit_page_copy_updates.py new file mode 100644 index 0000000000..0d1b8f8a69 --- /dev/null +++ b/data_fixtures/migrations/0003_unit_page_copy_updates.py @@ -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), + ]