# Generated by Django 4.1.4 on 2022-12-16 02:52
import django.utils.timezone
from django.db import migrations, models

import activities.models.post_types


def timelineevent_populate_published(apps, schema_editor):
    """
    Populates all timeline events' published date with their created date
    """
    TimelineEvent = apps.get_model("activities", "timelineevent")
    TimelineEvent.objects.update(published=models.F("created"))


class Migration(migrations.Migration):

    dependencies = [
        ("activities", "0004_emoji_post_emojis"),
    ]

    operations = [
        migrations.AddField(
            model_name="post",
            name="type",
            field=models.CharField(
                choices=[
                    ("Article", "Article"),
                    ("Audio", "Audio"),
                    ("Event", "Event"),
                    ("Image", "Image"),
                    ("Note", "Note"),
                    ("Page", "Page"),
                    ("Question", "Question"),
                    ("Video", "Video"),
                ],
                default="Note",
                max_length=20,
            ),
        ),
        migrations.AddField(
            model_name="post",
            name="type_data",
            field=models.JSONField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="timelineevent",
            name="published",
            field=models.DateTimeField(default=django.utils.timezone.now),
        ),
        migrations.AddField(
            model_name="timelineevent",
            name="seen",
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name="post",
            name="object_uri",
            field=models.CharField(blank=True, max_length=2048, null=True, unique=True),
        ),
        migrations.AlterField(
            model_name="post",
            name="type_data",
            field=models.JSONField(
                blank=True,
                null=True,
                decoder=activities.models.post_types.PostTypeDataDecoder,
                encoder=activities.models.post_types.PostTypeDataEncoder,
            ),
        ),
        migrations.AlterField(
            model_name="post",
            name="url",
            field=models.CharField(blank=True, max_length=2048, null=True),
        ),
        migrations.RunPython(
            code=timelineevent_populate_published,
            reverse_code=lambda a, s: None,
        ),
    ]
