# Generated by Django 3.2.18 on 2023-03-27 15:59

from django.db import migrations


def populate_finder_role(apps, schema_editor):
    Role = apps.get_model('projectroles', 'Role')
    role = Role(
        name='project finder',
        rank=50,
        project_types=['CATEGORY'],
        description='The project finder is able to see certain details of all '
        'categories and projects under a category for this role is given. '
        'They will not have access to the apps or data of those subprojects or '
        'categories until assigned a higher role. This role can only be '
        'assigned for categories.'
    )
    role.save()


def reverse_finder_role(apps, schema_editor):
    Role = apps.get_model('projectroles', 'Role')
    role = Role.objects.filter(name='project finder').first()
    if role:
        role.delete()


class Migration(migrations.Migration):

    dependencies = [
        ('projectroles', '0027_role_project_type'),
    ]

    operations = [
        migrations.RunPython(
            populate_finder_role, reverse_code=reverse_finder_role
        )
    ]
