# Generated by Django 4.2.16 on 2025-10-15 09:12

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="News",
            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, max_length=220, unique=True)),
                ("content", models.TextField()),
                ("excerpt", models.TextField(blank=True, max_length=300)),
                (
                    "featured_image",
                    models.ImageField(blank=True, upload_to="news/images/"),
                ),
                (
                    "featured_image_alt",
                    models.CharField(
                        blank=True,
                        help_text="Alt text untuk gambar utama",
                        max_length=200,
                    ),
                ),
                (
                    "youtube_url",
                    models.URLField(
                        blank=True, help_text="URL video YouTube untuk embed"
                    ),
                ),
                (
                    "video_file",
                    models.FileField(
                        blank=True,
                        help_text="File video lokal",
                        upload_to="news/videos/",
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "Draft"),
                            ("scheduled", "Terjadwal"),
                            ("published", "Dipublikasi"),
                            ("archived", "Diarsipkan"),
                        ],
                        default="draft",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("low", "Rendah"),
                            ("normal", "Normal"),
                            ("high", "Tinggi"),
                            ("urgent", "Mendesak"),
                        ],
                        default="normal",
                        max_length=10,
                    ),
                ),
                ("is_featured", models.BooleanField(default=False)),
                ("is_breaking", models.BooleanField(default=False)),
                ("published_date", models.DateTimeField(blank=True, null=True)),
                (
                    "scheduled_date",
                    models.DateTimeField(
                        blank=True,
                        help_text="Tanggal untuk publikasi otomatis",
                        null=True,
                    ),
                ),
                ("comments_count", models.PositiveIntegerField(default=0)),
                (
                    "total_views",
                    models.PositiveIntegerField(
                        default=0, help_text="Total jumlah views"
                    ),
                ),
                (
                    "reading_time",
                    models.PositiveIntegerField(
                        default=0, help_text="Estimasi waktu baca dalam menit"
                    ),
                ),
                ("meta_title", models.CharField(blank=True, max_length=60)),
                ("meta_description", models.CharField(blank=True, max_length=160)),
                (
                    "allow_comments",
                    models.BooleanField(
                        default=True, help_text="Izinkan komentar pada berita ini"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "author",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="news_articles",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Berita",
                "verbose_name_plural": "Berita",
                "ordering": ["-published_date", "-created_at"],
            },
        ),
        migrations.CreateModel(
            name="NewsCategory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, unique=True)),
                ("description", models.TextField(blank=True)),
                ("slug", models.SlugField(blank=True, max_length=120, unique=True)),
                (
                    "color",
                    models.CharField(
                        default="#007bff", help_text="Hex color code", max_length=7
                    ),
                ),
                (
                    "icon",
                    models.CharField(
                        blank=True, help_text="FontAwesome icon class", max_length=50
                    ),
                ),
                ("is_active", models.BooleanField(default=True)),
                (
                    "order",
                    models.PositiveIntegerField(default=0, help_text="Urutan kategori"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Kategori Berita",
                "verbose_name_plural": "Kategori Berita",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="NewsPageHeader",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(default="Berita Desa", max_length=200)),
                (
                    "description",
                    models.TextField(
                        blank=True,
                        default="Informasi terkini dan berita terbaru dari desa",
                    ),
                ),
                (
                    "background_image",
                    models.ImageField(blank=True, null=True, upload_to="page_headers/"),
                ),
                ("is_active", models.BooleanField(default=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Header Halaman Berita",
                "verbose_name_plural": "Header Halaman Berita",
            },
        ),
        migrations.CreateModel(
            name="NewsTag",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=50, unique=True)),
                ("slug", models.SlugField(blank=True, max_length=60, unique=True)),
                ("description", models.TextField(blank=True, verbose_name="Deskripsi")),
                (
                    "color",
                    models.CharField(
                        default="#6c757d", max_length=7, verbose_name="Warna"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "Tag Berita",
                "verbose_name_plural": "Tag Berita",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="NotificationSettings",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        max_length=100, unique=True, verbose_name="Nama Pengaturan"
                    ),
                ),
                (
                    "is_enabled",
                    models.BooleanField(
                        default=True, verbose_name="Aktifkan Notifikasi"
                    ),
                ),
                (
                    "show_in_navbar",
                    models.BooleanField(
                        default=True, verbose_name="Tampilkan di Navbar"
                    ),
                ),
                (
                    "auto_show_delay",
                    models.PositiveIntegerField(
                        default=1000,
                        help_text="Delay sebelum notifikasi muncul",
                        verbose_name="Delay Tampil (ms)",
                    ),
                ),
                (
                    "auto_hide_delay",
                    models.PositiveIntegerField(
                        default=15000,
                        help_text="Delay sebelum notifikasi hilang otomatis",
                        verbose_name="Delay Sembunyi (ms)",
                    ),
                ),
                (
                    "show_count_badge",
                    models.BooleanField(
                        default=True, verbose_name="Tampilkan Badge Jumlah"
                    ),
                ),
                (
                    "max_notifications",
                    models.PositiveIntegerField(
                        default=5,
                        help_text="Jumlah maksimal notifikasi yang ditampilkan",
                        verbose_name="Maksimal Notifikasi",
                    ),
                ),
                (
                    "slide_animation",
                    models.BooleanField(default=True, verbose_name="Animasi Slide"),
                ),
                (
                    "sound_enabled",
                    models.BooleanField(default=False, verbose_name="Aktifkan Suara"),
                ),
                (
                    "vibration_enabled",
                    models.BooleanField(default=True, verbose_name="Aktifkan Getaran"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Pengaturan Notifikasi",
                "verbose_name_plural": "Pengaturan Notifikasi",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="NewsShare",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "platform",
                    models.CharField(
                        choices=[
                            ("facebook", "Facebook"),
                            ("twitter", "Twitter"),
                            ("whatsapp", "WhatsApp"),
                            ("telegram", "Telegram"),
                            ("email", "Email"),
                            ("copy_link", "Copy Link"),
                            ("other", "Lainnya"),
                        ],
                        max_length=20,
                    ),
                ),
                ("ip_address", models.GenericIPAddressField()),
                ("session_key", models.CharField(blank=True, max_length=40)),
                ("user_agent", models.TextField(blank=True)),
                ("referrer", models.URLField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "news",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="shares",
                        to="news.news",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Share Berita",
                "verbose_name_plural": "Share Berita",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="NewsImage",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("image", models.ImageField(upload_to="news/gallery/")),
                (
                    "thumbnail",
                    models.ImageField(blank=True, upload_to="news/thumbnails/"),
                ),
                ("caption", models.CharField(blank=True, max_length=200)),
                ("alt_text", models.CharField(blank=True, max_length=100)),
                ("is_featured", models.BooleanField(default=False)),
                ("order", models.PositiveIntegerField(default=0)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "news",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="images",
                        to="news.news",
                    ),
                ),
            ],
            options={
                "verbose_name": "Gambar Berita",
                "verbose_name_plural": "Gambar Berita",
                "ordering": ["order", "created_at"],
            },
        ),
        migrations.CreateModel(
            name="NewsComment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("author_name", models.CharField(max_length=100)),
                ("author_email", models.EmailField(max_length=254)),
                ("author_website", models.URLField(blank=True)),
                ("content", models.TextField()),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("pending", "Menunggu Moderasi"),
                            ("approved", "Disetujui"),
                            ("rejected", "Ditolak"),
                            ("spam", "Spam"),
                        ],
                        default="pending",
                        max_length=20,
                    ),
                ),
                ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
                ("user_agent", models.TextField(blank=True)),
                ("is_author_verified", models.BooleanField(default=False)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "news",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="comments",
                        to="news.news",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="replies",
                        to="news.newscomment",
                    ),
                ),
            ],
            options={
                "verbose_name": "Komentar Berita",
                "verbose_name_plural": "Komentar Berita",
                "ordering": ["-created_at"],
            },
        ),
        migrations.AddField(
            model_name="news",
            name="category",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="news",
                to="news.newscategory",
            ),
        ),
        migrations.AddField(
            model_name="news",
            name="tags",
            field=models.ManyToManyField(
                blank=True, related_name="news", to="news.newstag"
            ),
        ),
        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, verbose_name="Judul")),
                ("slug", models.SlugField(blank=True, max_length=220, unique=True)),
                ("content", models.TextField(verbose_name="Isi Pengumuman")),
                (
                    "excerpt",
                    models.TextField(
                        blank=True, max_length=300, verbose_name="Ringkasan"
                    ),
                ),
                (
                    "announcement_type",
                    models.CharField(
                        choices=[
                            ("info", "Informasi"),
                            ("warning", "Peringatan"),
                            ("urgent", "Mendesak"),
                            ("schedule", "Jadwal"),
                            ("event", "Acara"),
                            ("service", "Layanan"),
                        ],
                        default="info",
                        max_length=20,
                        verbose_name="Jenis Pengumuman",
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "Draft"),
                            ("published", "Dipublikasi"),
                            ("archived", "Diarsipkan"),
                        ],
                        default="draft",
                        max_length=20,
                        verbose_name="Status",
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("low", "Rendah"),
                            ("normal", "Normal"),
                            ("high", "Tinggi"),
                            ("urgent", "Mendesak"),
                        ],
                        default="normal",
                        max_length=10,
                        verbose_name="Prioritas",
                    ),
                ),
                (
                    "is_pinned",
                    models.BooleanField(default=False, verbose_name="Pin di Atas"),
                ),
                (
                    "is_popup",
                    models.BooleanField(
                        default=False, verbose_name="Tampilkan sebagai Popup"
                    ),
                ),
                ("start_date", models.DateTimeField(verbose_name="Tanggal Mulai")),
                (
                    "end_date",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Tanggal Berakhir"
                    ),
                ),
                (
                    "target_audience",
                    models.CharField(
                        blank=True,
                        help_text="Contoh: Semua Warga, Ibu-ibu PKK, Remaja, dll",
                        max_length=100,
                        verbose_name="Target Audiens",
                    ),
                ),
                (
                    "contact_person",
                    models.CharField(
                        blank=True, max_length=100, verbose_name="Narahubung"
                    ),
                ),
                (
                    "contact_phone",
                    models.CharField(
                        blank=True, max_length=20, verbose_name="No. Telepon"
                    ),
                ),
                (
                    "location",
                    models.CharField(blank=True, max_length=200, verbose_name="Lokasi"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "author",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="announcements",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Penulis",
                    ),
                ),
            ],
            options={
                "verbose_name": "Pengumuman",
                "verbose_name_plural": "Pengumuman",
                "ordering": ["-is_pinned", "-priority", "-start_date"],
            },
        ),
        migrations.CreateModel(
            name="NewsView",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("ip_address", models.GenericIPAddressField()),
                ("user_agent", models.TextField(blank=True)),
                ("referrer", models.URLField(blank=True)),
                ("session_key", models.CharField(blank=True, max_length=40)),
                ("view_date", models.DateTimeField(auto_now_add=True)),
                (
                    "view_duration",
                    models.PositiveIntegerField(
                        default=0, help_text="Duration in seconds"
                    ),
                ),
                ("device_type", models.CharField(blank=True, max_length=20)),
                ("browser", models.CharField(blank=True, max_length=50)),
                ("operating_system", models.CharField(blank=True, max_length=50)),
                (
                    "news",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="view_records",
                        to="news.news",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Tampilan Berita",
                "verbose_name_plural": "Tampilan Berita",
                "ordering": ["-view_date"],
                "unique_together": {("news", "ip_address", "session_key")},
            },
        ),
        migrations.CreateModel(
            name="NewsLike",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("ip_address", models.GenericIPAddressField()),
                ("session_key", models.CharField(blank=True, max_length=40)),
                ("user_agent", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "news",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="likes",
                        to="news.news",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Like Berita",
                "verbose_name_plural": "Like Berita",
                "ordering": ["-created_at"],
                "unique_together": {("news", "ip_address", "session_key")},
            },
        ),
    ]
