# Generated by Django 3.1.8 on 2021-05-10 16:03

import django.contrib.gis.db.models.fields
import django.core.validators
from django.db import migrations, models
import dynamic_filenames
import stdimage.models


class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="StaticMapImage",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "center",
                    django.contrib.gis.db.models.fields.PointField(
                        geography=True, srid=4326, verbose_name="coordonnées"
                    ),
                ),
                (
                    "zoom",
                    models.IntegerField(
                        default=11,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(20),
                        ],
                        verbose_name="niveau de zoom",
                    ),
                ),
                (
                    "scale",
                    models.IntegerField(
                        default=1,
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(2),
                        ],
                        verbose_name="résolution de l'image",
                    ),
                ),
                (
                    "image",
                    stdimage.models.StdImageField(
                        upload_to=dynamic_filenames.FilePattern(
                            filename_pattern="{app_label}/{model_name}/{uuid:base32}{ext}"
                        ),
                        validators=[
                            django.core.validators.FileExtensionValidator(
                                allowed_extensions=["jpg", "png"]
                            )
                        ],
                        verbose_name="image",
                    ),
                ),
            ],
        ),
        migrations.AddIndex(
            model_name="staticmapimage",
            index=models.Index(fields=["center"], name="carte_stati_center_586687_idx"),
        ),
        migrations.AddConstraint(
            model_name="staticmapimage",
            constraint=models.UniqueConstraint(
                fields=("center", "zoom", "scale"), name="unique_for_position_options"
            ),
        ),
    ]
