# Generated by Django 4.2.7 on 2024-04-05 17:41

from django.db import migrations
from django.contrib.auth.models import Group, Permission

def update_groups_permissions(apps, schema_editor):

    all_perms = Permission.objects.all()

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

def no_permission_change(apps, schema_editor):
    pass

class Migration(migrations.Migration):

    dependencies = [
        ('agenda_culturel', '0044_alter_batchimportation_options_and_more'),
    ]

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