import apps.accounts.fields
import django.db.models.deletion
import django_ckeditor_5.fields
from django.db import migrations, models


class Migration(migrations.Migration):
    """
    Brands: sub-brands of a group, each served at /<slug>/ on the parent domain.

    A new table and nothing else. No existing model is touched, so an install
    that never enables the brands module carries an empty table and behaves
    exactly as it did before.

    A Brand is not a Tenant. See the docstring on the model: a Tenant is one
    install with its own database, a Brand is a section inside one install.
    """

    initial = True

    dependencies = [
        ('tenants', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Brand',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=120)),
                ('slug', models.SlugField(blank=True, help_text='The path this brand is served at, e.g. events gives /events/', max_length=140)),
                ('tagline', models.CharField(blank=True, help_text='One line under the name, e.g. Where Music Comes Alive', max_length=200)),
                ('intro', models.TextField(blank=True, help_text='Short summary, used on the brands index and in cards')),
                ('body', django_ckeditor_5.fields.CKEditor5Field(blank=True)),
                ('logo', apps.accounts.fields.WebPImageField(blank=True, null=True, upload_to='brands/logos/')),
                ('hero', apps.accounts.fields.WebPImageField(blank=True, null=True, upload_to='brands/hero/')),
                ('accent_colour', models.CharField(blank=True, help_text='Hex, e.g. #f06820. Falls back to the site accent when blank.', max_length=9)),
                ('external_domain', models.CharField(blank=True, help_text='The domain that redirects here, e.g. hpevents.uk. Recorded, not served.', max_length=190)),
                ('meta_description', models.TextField(blank=True)),
                ('meta_keywords', models.TextField(blank=True)),
                ('order', models.PositiveIntegerField(default=99)),
                ('is_active', models.BooleanField(default=True)),
                ('show_on_home', models.BooleanField(default=True, help_text='Include in the brands row on the homepage')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='brands', to='tenants.tenant')),
            ],
            options={
                'verbose_name': 'Brand',
                'verbose_name_plural': 'Brands',
                'ordering': ['order', 'name'],
                'unique_together': {('tenant', 'slug')},
            },
        ),
    ]
