# Generated by Django 5.1.6 on 2025-03-05 00:48

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


def create_permissions(apps, schema_editor) -> None:
    # Remnant of AAv0
    User = apps.get_model('auth', 'User')
    ContentType = apps.get_model('contenttypes', 'ContentType')
    Permission = apps.get_model('auth', 'Permission')
    ct = ContentType.objects.get_for_model(User)
    Permission.objects.get_or_create(codename="jabber_broadcast", content_type=ct, name="jabber_broadcast")
    Permission.objects.get_or_create(codename="jabber_broadcast_all", content_type=ct, name="jabber_broadcast_all")


def reverse(apps, schema_editor) -> None:
    pass


class Migration(migrations.Migration):

    replaces = [('openfire', '0001_initial'), ('openfire', '0002_service_permissions')]

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='OpenfireUser',
            fields=[
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='openfire', serialize=False, to=settings.AUTH_USER_MODEL)),
                ('username', models.CharField(max_length=254)),
            ],
            options={
                'default_permissions': (),
                'permissions': (('access_openfire', 'Can access the Openfire service'),),
            },
        ),
        migrations.RunPython(create_permissions, reverse)
    ]
