# Generated by Django 2.1.2 on 2018-10-02 01:28

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import feincms.module.medialibrary.fields
import feincms_banners.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [("medialibrary", "__first__")]

    operations = [
        migrations.CreateModel(
            name="Banner",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(default=True, verbose_name="is active"),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Only for internal use, will not be shown on the website.",
                        max_length=100,
                        verbose_name="name",
                    ),
                ),
                ("url", models.URLField(verbose_name="URL")),
                (
                    "type",
                    models.CharField(
                        choices=[
                            ("skyscraper", "skyscraper"),
                            ("leaderboard", "leaderboard"),
                            ("box", "box"),
                        ],
                        max_length=20,
                        verbose_name="type",
                    ),
                ),
                (
                    "code",
                    models.CharField(
                        default=feincms_banners.models.generate_key,
                        max_length=40,
                        unique=True,
                        verbose_name="code",
                    ),
                ),
                (
                    "active_from",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="active from"
                    ),
                ),
                (
                    "active_until",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="active until"
                    ),
                ),
                (
                    "embeds",
                    models.PositiveIntegerField(
                        default=0,
                        editable=False,
                        help_text="How many times has this banner been embdedded on a website?",
                        verbose_name="embeds",
                    ),
                ),
                (
                    "impressions",
                    models.PositiveIntegerField(
                        default=0,
                        editable=False,
                        help_text="How many times has an impression been registered using a Javascript callback, verifying that it actually was a browser? (Too low because of network issues and deactivated Javascript support in some browsers.)",
                        verbose_name="impressions",
                    ),
                ),
                (
                    "mediafile",
                    feincms.module.medialibrary.fields.MediaFileForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="medialibrary.MediaFile",
                        verbose_name="media file",
                    ),
                ),
            ],
            options={
                "verbose_name": "banner",
                "verbose_name_plural": "banners",
                "ordering": ["-active_from"],
            },
        ),
        migrations.CreateModel(
            name="Click",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "timestamp",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="timestamp"
                    ),
                ),
                (
                    "ip",
                    models.GenericIPAddressField(
                        blank=True, null=True, verbose_name="IP"
                    ),
                ),
                (
                    "user_agent",
                    models.TextField(blank=True, default="", verbose_name="user agent"),
                ),
                (
                    "referrer",
                    models.TextField(blank=True, default="", verbose_name="referrer"),
                ),
                (
                    "banner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="clicks",
                        to="feincms_banners.Banner",
                        verbose_name="banner",
                    ),
                ),
            ],
            options={
                "verbose_name": "click",
                "verbose_name_plural": "clicks",
                "ordering": ["-timestamp"],
            },
        ),
    ]
