# Generated by Django 2.2.24 on 2022-03-07 12:10
import re

from django.db import migrations


def remove_community_participation_read_more_prompts(apps, schema_editor):
    """
    Target read more prompts:
    For more information, read about Judging at Mass Challenge.
    Read more about Mentoring at Mass Challenge.
    Read more about being an Entrepreneur  at Mass Challenge.
    Read more about Office Hours  at Mass Challenge.
    Read more about Speaking  at Mass Challenge.
    """
    CommunityParticipation = apps.get_model(
        'accelerator', 'CommunityParticipation')
    for participation in CommunityParticipation.objects.all():
        # remove prompts starting with "Read more about"
        participation.description = re.sub(
            r' Read more about[a-zA-Z ]*.$', '', participation.description)
        # remove prompts starting with "For more information"
        participation.description = re.sub(
            r' For more information[a-zA-Z, ]*.$', '', participation.description)
        # replace non-ascii char "’" with "'"
        participation.description = participation.description.replace('\u2019', "'")
        participation.save()


class Migration(migrations.Migration):
    dependencies = [
        ('accelerator', '0087_update_startup_profile'),
    ]

    operations = [
        migrations.RunPython(remove_community_participation_read_more_prompts,
                             migrations.RunPython.noop)
    ]

add data migration