From 575e18aedda0f299de7d1d5b2a4c31949e3a191b Mon Sep 17 00:00:00 2001 From: annagav Date: Wed, 4 Dec 2024 13:27:44 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"Migrate=20existing=20(string)=20value?= =?UTF-8?q?s=20to=20populate=20min=5Fweeks=20and=20max=5Fweeks=20=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e0733c4b66820b64916ec92f379529a103606ba2. --- cms/migrations/0041_populate_min_weeks.py | 48 ----------------------- 1 file changed, 48 deletions(-) delete mode 100644 cms/migrations/0041_populate_min_weeks.py diff --git a/cms/migrations/0041_populate_min_weeks.py b/cms/migrations/0041_populate_min_weeks.py deleted file mode 100644 index 2f2b939732..0000000000 --- a/cms/migrations/0041_populate_min_weeks.py +++ /dev/null @@ -1,48 +0,0 @@ -# Generated by Django 4.2.16 on 2024-12-03 18:25 - -import re - -from django.db import migrations - - -def populate_max_min_weeks_fields(apps, schema_editor): - CoursePage = apps.get_model("cms", "CoursePage") - for course_page in CoursePage.objects.all(): - if course_page.length: - duration_nums = re.findall(r"\d+", course_page.length) - if len(duration_nums) > 0: - course_page.max_weeks = duration_nums[0] - course_page.min_weeks = duration_nums[0] - course_page.save() - - ProgramPage = apps.get_model("cms", "ProgramPage") - for program_page in ProgramPage.objects.all(): - if program_page.length and program_page.max_weeks is None: - duration_string = re.findall( - r"\d+[\s-]*[\d+\s]*week", program_page.length.lower() - ) - if duration_string: - duration_nums = re.findall(r"\d+", duration_string[0]) - else: - duration_string = re.findall( - r"\d+[\s-]*[\d+\s]*month", program_page.length.lower() - ) - duration_nums_in_month = re.findall(r"\d+", duration_string[0]) - duration_nums = [num * 4 for num in duration_nums_in_month] - program_page.min_weeks = duration_nums[0] - program_page.max_weeks = ( - duration_nums[1] if len(duration_nums) > 1 else duration_nums[0] - ) - program_page.save() - - -class Migration(migrations.Migration): - dependencies = [ - ("cms", "0040_coursepage_max_weeks_coursepage_min_weeks_and_more"), - ] - - operations = [ - migrations.RunPython( - populate_max_min_weeks_fields, reverse_code=migrations.RunPython.noop - ), - ]