# Generated by Django 2.1.7 on 2019-02-15 17:04

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

import parler.models

import richie.apps.core.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [("cms", "0022_auto_20180620_1551")]

    operations = [
        migrations.CreateModel(
            name="Person",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "first_name",
                    models.CharField(max_length=200, verbose_name="First name"),
                ),
                (
                    "last_name",
                    models.CharField(max_length=200, verbose_name="Last name"),
                ),
                (
                    "extended_object",
                    models.OneToOneField(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="cms.Page",
                    ),
                ),
            ],
            options={"verbose_name": "person"},
        ),
        migrations.CreateModel(
            name="PersonPluginModel",
            fields=[
                (
                    "cmsplugin_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="persons_personpluginmodel",
                        serialize=False,
                        to="cms.CMSPlugin",
                    ),
                ),
                (
                    "page",
                    models.ForeignKey(
                        limit_choices_to={
                            "person__isnull": False,
                            "publisher_is_draft": True,
                        },
                        on_delete=django.db.models.deletion.CASCADE,
                        to="cms.Page",
                    ),
                ),
            ],
            options={"verbose_name": "person plugin model"},
            bases=(richie.apps.core.models.PagePluginMixin, "cms.cmsplugin"),
        ),
        migrations.CreateModel(
            name="PersonTitle",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                )
            ],
            options={"verbose_name": "person title"},
            bases=(parler.models.TranslatableModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name="PersonTitleTranslation",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "language_code",
                    models.CharField(
                        db_index=True, max_length=15, verbose_name="Language"
                    ),
                ),
                ("title", models.CharField(max_length=200, verbose_name="Title")),
                (
                    "abbreviation",
                    models.CharField(max_length=10, verbose_name="Title abbreviation"),
                ),
                (
                    "master",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="translations",
                        to="persons.PersonTitle",
                    ),
                ),
            ],
            options={"verbose_name": "person title translation"},
        ),
        migrations.AddField(
            model_name="person",
            name="person_title",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="persons",
                to="persons.PersonTitle",
            ),
        ),
        migrations.AddField(
            model_name="person",
            name="public_extension",
            field=models.OneToOneField(
                editable=False,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="draft_extension",
                to="persons.Person",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="persontitletranslation", unique_together={("language_code", "master")}
        ),
    ]
