# Generated by Django 3.2.4 on 2021-06-16 14:33

import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="BiobasedOriginMaterial",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        db_index=True, max_length=50, unique=True, verbose_name="Nom"
                    ),
                ),
            ],
            options={
                "verbose_name": "Matériau biosourcé",
                "verbose_name_plural": "Matériaux biosourcés",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="Enterprise",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(db_index=True, max_length=200, verbose_name="Nom"),
                ),
                (
                    "website",
                    models.URLField(blank=True, db_index=True, verbose_name="Site web"),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, max_length=1000, verbose_name="Description"
                    ),
                ),
                (
                    "annual_sales",
                    models.PositiveIntegerField(
                        blank=True,
                        choices=[
                            (1, "< 2 millions €"),
                            (2, "2 à 10 millions €"),
                            (3, "10 à 50 millions €"),
                            (4, "50 à 200 millions €"),
                            (5, "200 à 1500 millions €"),
                            (6, "> 1500 millions €"),
                        ],
                        db_index=True,
                        null=True,
                        verbose_name="Chiffre d'affaires",
                    ),
                ),
                (
                    "n_employees",
                    models.PositiveIntegerField(
                        blank=True,
                        choices=[
                            (1, "1"),
                            (2, "2 - 9"),
                            (10, "10 - 49"),
                            (50, "50 - 249"),
                            (250, "250 - 999"),
                            (1000, "1000 - 4999"),
                            (5000, "5000+"),
                        ],
                        db_index=True,
                        null=True,
                        verbose_name="Nombre d'employés",
                    ),
                ),
                (
                    "added",
                    models.DateField(auto_now_add=True, verbose_name="Date d'ajout"),
                ),
                (
                    "updated",
                    models.DateField(auto_now=True, verbose_name="Date de mise à jour"),
                ),
            ],
            options={
                "verbose_name": "Entreprise",
                "verbose_name_plural": "Entreprises",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="MaterialTypeCategory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        max_length=200, unique=True, verbose_name="Nom de la catégorie"
                    ),
                ),
                (
                    "order",
                    models.PositiveSmallIntegerField(
                        db_index=True, default=99, verbose_name="Ordre d'affichage"
                    ),
                ),
            ],
            options={
                "verbose_name": "Catégorie de typologies",
                "verbose_name_plural": "Catégories de typologies",
                "ordering": ["order"],
            },
        ),
        migrations.CreateModel(
            name="MaterialType",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        max_length=200,
                        unique=True,
                        verbose_name="Typologie de matériaux",
                    ),
                ),
                (
                    "order",
                    models.PositiveSmallIntegerField(
                        db_index=True, default=99, verbose_name="Ordre d'affichage"
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="usages",
                        to="ecoliste.materialtypecategory",
                        verbose_name="Catégorie de typologie",
                    ),
                ),
            ],
            options={
                "verbose_name": "Typologie de matériaux",
                "verbose_name_plural": "Typologies de matériaux",
                "ordering": ["category", "order"],
            },
        ),
        migrations.CreateModel(
            name="Contact",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "firstname",
                    models.CharField(
                        db_index=True, max_length=50, verbose_name="Prénom"
                    ),
                ),
                (
                    "surname",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        max_length=50,
                        verbose_name="Nom de famille",
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, max_length=200, verbose_name="Description"
                    ),
                ),
                (
                    "phone1",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        max_length=25,
                        verbose_name="Téléphone 1",
                    ),
                ),
                (
                    "phone2",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        max_length=25,
                        verbose_name="Téléphone 2",
                    ),
                ),
                (
                    "mail",
                    models.EmailField(
                        blank=True,
                        db_index=True,
                        max_length=254,
                        null=True,
                        verbose_name="Adresse mail",
                    ),
                ),
                (
                    "enterprise",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="contacts",
                        to="ecoliste.enterprise",
                        verbose_name="Entreprise",
                    ),
                ),
            ],
            options={
                "verbose_name": "Contact",
                "verbose_name_plural": "Contacts",
            },
        ),
        migrations.CreateModel(
            name="Address",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "text_version",
                    models.CharField(max_length=400, verbose_name="Adresse textuelle"),
                ),
                (
                    "geolocation",
                    django.contrib.gis.db.models.fields.PointField(
                        geography=True, srid=4326, verbose_name="Coordonnées"
                    ),
                ),
                (
                    "is_production",
                    models.BooleanField(verbose_name="Est un lieu de production"),
                ),
                (
                    "enterprise",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="addresses",
                        to="ecoliste.enterprise",
                        verbose_name="Entreprise",
                    ),
                ),
            ],
            options={
                "verbose_name": "Adresse",
                "verbose_name_plural": "Adresses",
            },
        ),
        migrations.CreateModel(
            name="MaterialByEnterprise",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "origin",
                    models.PositiveSmallIntegerField(
                        choices=[
                            (1, "De réemploi"),
                            (2, "Biosourcé"),
                            (3, "Recyclé"),
                            (4, "Réutilisable"),
                        ],
                        verbose_name="Origine",
                    ),
                ),
                (
                    "address",
                    models.ManyToManyField(
                        blank=True,
                        db_index=True,
                        related_name="products",
                        to="ecoliste.Address",
                        verbose_name="Adresse de production",
                    ),
                ),
                (
                    "biobased_material",
                    models.ManyToManyField(
                        blank=True,
                        db_index=True,
                        related_name="products",
                        to="ecoliste.BiobasedOriginMaterial",
                        verbose_name="Matériau biosourcé",
                    ),
                ),
                (
                    "enterprise",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="products",
                        to="ecoliste.enterprise",
                        verbose_name="Entreprise",
                    ),
                ),
                (
                    "type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="products",
                        to="ecoliste.materialtype",
                        verbose_name="Typologie",
                    ),
                ),
            ],
            options={
                "verbose_name": "Matériau produit",
                "verbose_name_plural": "Matériaux produits",
                "ordering": ["type"],
                "unique_together": {("enterprise", "type", "origin")},
            },
        ),
    ]
