# Generated by Django 2.2.9 on 2020-03-30 10:45

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ("models", "5972_iiifmanifest"),
    ]

    def forwards_func(apps, schema_editor):
        permission = apps.get_model("auth", "Permission")
        view = permission.objects.get(codename="view_resourceinstance")
        change = permission.objects.get(codename="change_resourceinstance")
        delete = permission.objects.get(codename="delete_resourceinstance")
        add = permission.objects.get(codename="add_resourceinstance")
        view.name = "Read resource"
        change.name = "Update resource"
        delete.name = "Delete resource"
        add.name = "Create resource"
        view.save()
        change.save()
        delete.save()
        add.save()

    def reverse_func(apps, schema_editor):
        permission = apps.get_model("auth", "Permission")
        view = permission.objects.get(codename="view_resourceinstance")
        change = permission.objects.get(codename="change_resourceinstance")
        delete = permission.objects.get(codename="delete_resourceinstance")
        add = permission.objects.get(codename="add_resourceinstance")
        view.name = "Can view resource instance"
        change.name = "Can change resource instance"
        delete.name = "Can delete resource instance"
        add.name = "Can add resource instance"
        view.save()
        change.save()
        delete.save()
        add.save()

    operations = [
        migrations.AlterModelOptions(
            name="resourceinstance",
            options={
                "managed": True,
                "permissions": (("no_access_to_resourceinstance", "No Access"),),
            },
        ),
        migrations.RunPython(forwards_func, reverse_func),
    ]
