# Create groups for several tasks

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


def groups_permissions_creation(apps, schema_editor):
    user_roles = ["Automation Manager", "Q&A Manager", "Receptionist"]

    for name in user_roles:
        Group.objects.create(name=name)

def groups_permissions_deletion(apps, schema_editor):
    user_roles = ["Automation Manager", "Q&A Manager", "Receptionist"]

    for name in user_roles:
        Group.objects.filter(name=name).delete()




class Migration(migrations.Migration):

    dependencies = [
        ('agenda_culturel', '0035_alter_event_location'),
    ]

    operations = [
        migrations.RunPython(groups_permissions_creation, reverse_code=groups_permissions_deletion),
    ]
