# Generated by Django 3.1.8 on 2021-06-06 18:51

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


def create_shift_user_data(apps, schema_editor):
    TapirUser = apps.get_model("accounts", "TapirUser")
    ShiftUserData = apps.get_model("shifts", "ShiftUserData")

    for u in TapirUser.objects.all():
        ShiftUserData.objects.create(user=u)


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("shifts", "0003_shifttemplategroup_week_index"),
    ]

    operations = [
        migrations.AlterModelOptions(
            name="shiftattendance",
            options={"ordering": ["shift__start_time"]},
        ),
        migrations.CreateModel(
            name="ShiftUserData",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "attendance_mode",
                    models.CharField(
                        choices=[("regular", "Regular"), ("flying", "Flying")],
                        default="regular",
                        max_length=32,
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="shift_user_data",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.RunPython(create_shift_user_data),
    ]
