# Generated by Django 2.2.4 on 2019-10-07 08:03
from django.core.cache import cache
from django.db import migrations


def mail_migrator(app, schema_editor):
    Event_SettingsStore = app.get_model('pretixbase', 'Event_SettingsStore')

    for ss in Event_SettingsStore.objects.filter(
        key__in=['mail_text_order_approved', 'mail_text_order_placed', 'mail_text_order_placed_require_approval']
    ):
        chgd = ss.value.replace("{date}", "{expire_date}")
        if chgd != ss.value:
            ss.value = chgd
            ss.save()
            cache.delete('hierarkey_{}_{}'.format('event', ss.object_id))


class Migration(migrations.Migration):

    dependencies = [
        ('pretixbase', '0134_auto_20190909_1042'),
    ]

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