# Generated by Django 4.2.2 on 2023-06-20 21:51

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("dati_geo_app", "0007_delete_indirizzo"),
        ("contenttypes", "0002_remove_content_type_name"),
    ]

    operations = [
        migrations.CreateModel(
            name="Recapito",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "polymorphic_ctype",
                    models.ForeignKey(
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="polymorphic_%(app_label)s.%(class)s_set+",
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "verbose_name": "contatto di rubrica",
                "verbose_name_plural": "contatti di rubrica",
            },
        ),
        migrations.CreateModel(
            name="SoggettoContattabile",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "polymorphic_ctype",
                    models.ForeignKey(
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="polymorphic_%(app_label)s.%(class)s_set+",
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "verbose_name": "soggetto contattabile",
                "verbose_name_plural": "soggetti contattabili",
            },
        ),
        migrations.CreateModel(
            name="Email",
            fields=[
                (
                    "recapito_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.recapito",
                    ),
                ),
                ("indirizzo_email", models.EmailField(max_length=254)),
                ("note", models.CharField(blank=True, default="", max_length=64)),
            ],
            options={
                "verbose_name": "email",
                "verbose_name_plural": "email",
            },
            bases=("contatti_app.recapito",),
        ),
        migrations.CreateModel(
            name="Fax",
            fields=[
                (
                    "recapito_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.recapito",
                    ),
                ),
                ("numero", models.CharField(max_length=20)),
                ("note", models.CharField(blank=True, default="", max_length=64)),
            ],
            options={
                "verbose_name": "fax",
                "verbose_name_plural": "fax",
            },
            bases=("contatti_app.recapito",),
        ),
        migrations.CreateModel(
            name="Indirizzo",
            fields=[
                (
                    "recapito_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.recapito",
                    ),
                ),
                (
                    "duf",
                    models.CharField(
                        help_text="Il nome della via/piazza/ecc...",
                        max_length=256,
                        verbose_name="denominazione urbanistica ufficiale",
                    ),
                ),
                ("civico", models.CharField(max_length=256)),
                (
                    "altro",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Es.: interno, scala, appartamento...",
                        max_length=2048,
                    ),
                ),
                (
                    "cap",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="dati_geo_app.cap",
                    ),
                ),
                (
                    "comune",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="dati_geo_app.comune",
                    ),
                ),
                (
                    "dug",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="dati_geo_app.dug",
                        verbose_name="denominazione urbanistica generica",
                    ),
                ),
                (
                    "nazione",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="dati_geo_app.nazione",
                    ),
                ),
            ],
            options={
                "verbose_name": "indirizzo",
                "verbose_name_plural": "indirizzi",
                "abstract": False,
            },
            bases=("contatti_app.recapito", models.Model),
        ),
        migrations.CreateModel(
            name="PersonaFisica",
            fields=[
                (
                    "soggettocontattabile_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.soggettocontattabile",
                    ),
                ),
                ("titolo", models.CharField(blank=True, default="", max_length=10)),
                ("nome", models.CharField(max_length=60)),
                ("cognome", models.CharField(max_length=60)),
                ("is_privato", models.BooleanField(default=True)),
            ],
            options={
                "verbose_name": "persona fisica",
                "verbose_name_plural": "persone fisiche",
            },
            bases=("contatti_app.soggettocontattabile",),
        ),
        migrations.CreateModel(
            name="PersonaGiuridica",
            fields=[
                (
                    "soggettocontattabile_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.soggettocontattabile",
                    ),
                ),
                ("denominazione", models.CharField(max_length=80)),
            ],
            options={
                "verbose_name": "persona giuridica",
                "verbose_name_plural": "persone giuridiche",
            },
            bases=("contatti_app.soggettocontattabile",),
        ),
        migrations.CreateModel(
            name="Telefono",
            fields=[
                (
                    "recapito_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.recapito",
                    ),
                ),
                ("numero", models.CharField(max_length=20)),
                ("interno", models.CharField(blank=True, default="", max_length=20)),
                ("note", models.CharField(blank=True, default="", max_length=64)),
            ],
            options={
                "verbose_name": "telefono",
                "verbose_name_plural": "telefono",
            },
            bases=("contatti_app.recapito",),
        ),
        migrations.CreateModel(
            name="Societa",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("ragione_sociale", models.CharField(max_length=1024)),
                (
                    "nazione",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="societa",
                        to="dati_geo_app.nazione",
                    ),
                ),
                (
                    "soggetto",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="societa",
                        to="contatti_app.soggettocontattabile",
                    ),
                ),
            ],
            options={
                "verbose_name": "societa",
                "verbose_name_plural": "societa",
            },
        ),
        migrations.AddField(
            model_name="recapito",
            name="soggetto",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="contatti",
                to="contatti_app.soggettocontattabile",
            ),
        ),
        migrations.CreateModel(
            name="Pec",
            fields=[
                (
                    "email_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.email",
                    ),
                ),
            ],
            options={
                "verbose_name": "pec",
                "verbose_name_plural": "pec",
            },
            bases=("contatti_app.email",),
        ),
        migrations.CreateModel(
            name="ContattoAziendale",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_personale", models.BooleanField(default=True)),
                (
                    "azienda",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="contatti_azienda",
                        to="contatti_app.societa",
                    ),
                ),
                (
                    "persona",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="aziende_correlate",
                        to="contatti_app.personafisica",
                    ),
                ),
            ],
            options={
                "verbose_name": "Contatto aziendale",
                "verbose_name_plural": "Contatti aziendali",
            },
        ),
        migrations.CreateModel(
            name="Sede",
            fields=[
                (
                    "indirizzo_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="contatti_app.indirizzo",
                    ),
                ),
                ("is_legale", models.BooleanField(default=False)),
                (
                    "societa",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sedi",
                        to="contatti_app.societa",
                    ),
                ),
            ],
            options={
                "verbose_name": "sede",
                "verbose_name_plural": "sedi",
            },
            bases=("contatti_app.indirizzo",),
        ),
    ]
