# Generated by Django 4.2.7 on 2024-04-27 16:29

from django.db import migrations

def update_groups_permissions(apps, schema_editor):
    Group = apps.get_model("auth", "Group")
    Permission = apps.get_model("auth", "Permission")

    all_perms = Permission.objects.all()

    # set permissions for moderators
    moderator_perms = [i for i in all_perms if i.content_type.app_label == 'agenda_culturel' and i.content_type.model in ['place']]
    Group.objects.get(name="Moderator").permissions.add(*moderator_perms)

def no_permission_change(apps, schema_editor):
    pass

class Migration(migrations.Migration):

    dependencies = [
        ('agenda_culturel', '0058_place_city_alter_place_address'),
    ]

    operations = [
        migrations.RunPython(update_groups_permissions, reverse_code=no_permission_change),
    ]
