# Generated by Django 4.2.10 on 2025-03-19 07:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django_ckeditor_5.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Category",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100)),
                ("slug", models.SlugField(blank=True, unique=True)),
                ("description", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name_plural": "Categories",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="Tag",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=50)),
                ("slug", models.SlugField(blank=True, unique=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="Article",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=200)),
                ("slug", models.SlugField(blank=True, unique=True)),
                ("subtitle", models.CharField(blank=True, max_length=200)),
                (
                    "content",
                    django_ckeditor_5.fields.CKEditor5Field(verbose_name="Content"),
                ),
                (
                    "featured_image",
                    models.ImageField(
                        blank=True,
                        help_text="Main image for the article",
                        null=True,
                        upload_to="news/featured/",
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[("draft", "Draft"), ("published", "Published")],
                        default="draft",
                        max_length=10,
                    ),
                ),
                ("published_date", models.DateTimeField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "meta_description",
                    models.CharField(
                        blank=True,
                        help_text="A brief description for SEO (max 160 characters)",
                        max_length=160,
                    ),
                ),
                ("views_count", models.PositiveIntegerField(default=0)),
                (
                    "is_featured",
                    models.BooleanField(
                        default=False, help_text="Feature this article on the homepage"
                    ),
                ),
                (
                    "author",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="articles",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="articles",
                        to="news.category",
                    ),
                ),
                (
                    "tags",
                    models.ManyToManyField(
                        blank=True, related_name="articles", to="news.tag"
                    ),
                ),
            ],
            options={
                "ordering": ["-published_date", "-created_at"],
                "indexes": [
                    models.Index(
                        fields=["-published_date", "-created_at"],
                        name="news_articl_publish_86740f_idx",
                    ),
                    models.Index(
                        fields=["status"], name="news_articl_status_a95c4c_idx"
                    ),
                    models.Index(
                        fields=["is_featured"], name="news_articl_is_feat_0df2de_idx"
                    ),
                ],
            },
        ),
    ]
