# Generated by Django 4.2.8 on 2023-12-29 07:03

from django.db import migrations, models


def migrate_data(apps, schema_editor):
    APIdentity = apps.get_model("users", "APIdentity")
    APIdentity.objects.filter(local=False).update(anonymous_viewable=False)
    APIdentity.objects.filter(user__isnull=False).update(anonymous_viewable=False)
    APIdentity.objects.filter(user__is_active=False).update(anonymous_viewable=False)
    APIdentity.objects.filter(user__preference__no_anonymous_view=True).update(
        anonymous_viewable=False
    )


class Migration(migrations.Migration):
    dependencies = [
        ("users", "0017_mastodon_site_username_bd2db5_idx"),
    ]

    operations = [
        migrations.AddField(
            model_name="apidentity",
            name="anonymous_viewable",
            field=models.BooleanField(default=True),
        ),
        migrations.RunPython(migrate_data),
    ]
