# Generated by Django 6.0.5 on 2026-05-29 10:09

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name="Announcement",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=200)),
                ("body", models.TextField()),
                (
                    "category",
                    models.CharField(
                        choices=[
                            ("taarifa", "Taarifa — Local Alert"),
                            ("shughuli", "Shughuli — Event"),
                            ("biashara", "Biashara — Business Advert"),
                            ("kazi", "Kazi — Job Listing"),
                            ("matatu", "Matatu — Transport Update"),
                            ("harambee", "Harambee — Fundraiser"),
                            ("general", "General Announcement"),
                        ],
                        default="general",
                        max_length=30,
                    ),
                ),
                (
                    "neighborhood",
                    models.CharField(
                        choices=[
                            ("all", "All Thika"),
                            ("makongeni", "Makongeni"),
                            ("township", "Township"),
                            ("landless", "Landless"),
                            ("kiandutu", "Kiandutu"),
                            ("gatuanyaga", "Gatuanyaga"),
                            ("thika_greens", "Thika Greens"),
                            ("section_9", "Section 9"),
                            ("ngoigwa", "Ngoigwa"),
                            ("kamenu", "Kamenu"),
                        ],
                        default="all",
                        max_length=30,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("normal", "Normal"),
                            ("high", "High — shown prominently"),
                            ("urgent", "Urgent — red alert"),
                        ],
                        default="normal",
                        max_length=10,
                    ),
                ),
                (
                    "image",
                    models.ImageField(
                        blank=True, null=True, upload_to="announcements/"
                    ),
                ),
                (
                    "link",
                    models.URLField(
                        blank=True, help_text="Optional external link", null=True
                    ),
                ),
                ("is_active", models.BooleanField(default=True)),
                (
                    "is_broadcast",
                    models.BooleanField(
                        default=False,
                        help_text="If true, this will be sent as a message to relevant chat rooms",
                    ),
                ),
                ("broadcast_done", models.BooleanField(default=False)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "expires_at",
                    models.DateTimeField(
                        blank=True, help_text="Leave blank to never expire", null=True
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="announcements",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="AnnouncementView",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("viewed_at", models.DateTimeField(auto_now_add=True)),
                (
                    "announcement",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="views",
                        to="announcements.announcement",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="announcement_views",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "unique_together": {("announcement", "user")},
            },
        ),
    ]
