# Generated by Django 6.0.4 on 2026-06-06 02:55

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contacts', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PublicationCategory',
            fields=[
                ('id', models.UUIDField(default=apps.publications.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('slug', models.SlugField(blank=True, max_length=100, null=True, unique=True)),
                ('name', models.CharField(max_length=100, unique=True)),
                ('description', models.TextField(blank=True)),
                ('color', models.CharField(default='#6b7280', max_length=7)),
            ],
            options={
                'db_table': 'publication_categories',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='CSISPublication',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('csis_id', models.IntegerField(unique=True)),
                ('title', models.CharField(max_length=512)),
                ('slug', models.SlugField(max_length=512, unique=True)),
                ('date_publish', models.DateField(blank=True, null=True)),
                ('authors', models.JSONField(default=list)),
                ('topics', models.JSONField(default=list)),
                ('category_name', models.CharField(blank=True, max_length=255)),
                ('category_slug', models.CharField(blank=True, max_length=255)),
                ('image', models.URLField(blank=True, max_length=1024)),
                ('file_url', models.URLField(blank=True, max_length=1024)),
                ('description', models.TextField(blank=True)),
                ('viewed', models.IntegerField(default=0)),
                ('download_count', models.IntegerField(default=0)),
                ('synced_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'csis_publications',
                'ordering': ['-date_publish'],
                'indexes': [models.Index(fields=['category_slug'], name='csis_public_categor_7a2678_idx'), models.Index(fields=['date_publish'], name='csis_public_date_pu_762195_idx')],
            },
        ),
        migrations.CreateModel(
            name='ExternalPublication',
            fields=[
                ('id', models.UUIDField(default=apps.publications.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255)),
                ('source', models.CharField(max_length=255)),
                ('url', models.URLField(blank=True)),
                ('authors', models.JSONField(default=list)),
                ('published_date', models.DateField(blank=True, null=True)),
                ('description', models.TextField(blank=True)),
                ('tags', models.JSONField(default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('byline_contacts', models.ManyToManyField(blank=True, related_name='external_publications', to='contacts.contact')),
            ],
            options={
                'db_table': 'external_publications',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Publication',
            fields=[
                ('id', models.UUIDField(default=apps.publications.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255)),
                ('content', models.TextField()),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('review', 'In Review'), ('approved', 'Approved'), ('published', 'Published'), ('rejected', 'Rejected')], default='draft', max_length=20)),
                ('published_at', models.DateTimeField(blank=True, null=True)),
                ('tags', models.JSONField(default=list)),
                ('cover_image', models.ImageField(blank=True, null=True, upload_to='publication_covers/')),
                ('attachments', models.JSONField(default=list)),
                ('views', models.IntegerField(default=0)),
                ('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='publications', to=settings.AUTH_USER_MODEL)),
                ('byline_contact', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='byline_publications', to='contacts.contact')),
                ('co_author_contacts', models.ManyToManyField(blank=True, related_name='co_byline_publications', to='contacts.contact')),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='publications', to='publications.publicationcategory')),
            ],
            options={
                'db_table': 'publications',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Author',
            fields=[
                ('id', models.UUIDField(default=apps.publications.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('bio', models.TextField(blank=True)),
                ('expertise', models.JSONField(default=list)),
                ('social_links', models.JSONField(default=dict)),
                ('contact', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='author_profile', to='contacts.contact')),
                ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='author_profile', to=settings.AUTH_USER_MODEL)),
                ('publications', models.ManyToManyField(blank=True, related_name='co_authors', to='publications.publication')),
            ],
            options={
                'db_table': 'authors',
            },
        ),
        migrations.CreateModel(
            name='Submission',
            fields=[
                ('id', models.UUIDField(default=apps.publications.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('status', models.CharField(choices=[('submitted', 'Submitted'), ('under_review', 'Under Review'), ('revision_requested', 'Revision Requested'), ('accepted', 'Accepted'), ('rejected', 'Rejected')], default='submitted', max_length=20)),
                ('review_notes', models.TextField(blank=True)),
                ('reviewed_at', models.DateTimeField(blank=True, null=True)),
                ('submitted_at', models.DateTimeField(auto_now_add=True)),
                ('publication', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='submission', to='publications.publication')),
                ('reviewed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('submitted_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='submissions', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'submissions',
                'ordering': ['-submitted_at'],
            },
        ),
        migrations.AddIndex(
            model_name='publication',
            index=models.Index(fields=['status'], name='publication_status_c17c82_idx'),
        ),
        migrations.AddIndex(
            model_name='publication',
            index=models.Index(fields=['published_at'], name='publication_publish_be13ef_idx'),
        ),
        migrations.AddIndex(
            model_name='submission',
            index=models.Index(fields=['status'], name='submissions_status_dcc854_idx'),
        ),
    ]
