# Generated by Django 2.1.5 on 2019-02-04 13:02

import django.db.migrations.operations.special
from django.db import migrations, models


def enable_notifications_for_everyone(apps, schema_editor):
    NotificationSetting = apps.get_model('pretixbase', 'NotificationSetting')
    User = apps.get_model('pretixbase', 'User')
    create = []
    for u in User.objects.iterator():
        create.append(NotificationSetting(
            user=u,
            action_type='pretix.event.order.refund.requested',
            event=None,
            method='mail',
            enabled=True
        ))
        if len(create) > 200:
            NotificationSetting.objects.bulk_create(create)
            create.clear()
    NotificationSetting.objects.bulk_create(create)
    create.clear()


class Migration(migrations.Migration):
    replaces = [('pretixbase', '0105_auto_20190112_1512'), ('pretixbase', '0106_auto_20190118_1527'),
                ('pretixbase', '0107_auto_20190129_1337')]

    dependencies = [
        ('pretixbase', '0104_auto_20181114_1526'),
    ]

    operations = [
        migrations.AddField(
            model_name='invoiceaddress',
            name='beneficiary',
            field=models.TextField(blank=True, verbose_name='Beneficiary'),
        ),
        migrations.AddField(
            model_name='invoice',
            name='invoice_to_beneficiary',
            field=models.TextField(blank=True, null=True, verbose_name='Beneficiary'),
        ),
        migrations.RunPython(
            code=enable_notifications_for_everyone,
            reverse_code=django.db.migrations.operations.special.RunPython.noop,
        ),
        migrations.AlterField(
            model_name='order',
            name='datetime',
            field=models.DateTimeField(db_index=True, verbose_name='Date'),
        ),
    ]
