diff options
Diffstat (limited to 'ishtar_common/migrations')
| -rw-r--r-- | ishtar_common/migrations/0243_default_biographicalnote_permissions.json | 201 | ||||
| -rw-r--r-- | ishtar_common/migrations/0243_default_biographicalnote_permissions.py | 32 | 
2 files changed, 233 insertions, 0 deletions
diff --git a/ishtar_common/migrations/0243_default_biographicalnote_permissions.json b/ishtar_common/migrations/0243_default_biographicalnote_permissions.json new file mode 100644 index 000000000..c2144a855 --- /dev/null +++ b/ishtar_common/migrations/0243_default_biographicalnote_permissions.json @@ -0,0 +1,201 @@ +[ +    { +        "model": "contenttypes.contenttype", +        "fields": { +            "app_label": "ishtar_common", +            "model": "biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can add Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "add_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can change Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "change_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can delete Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "delete_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can view Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "view_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can view own Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "view_own_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can add own Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "add_own_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can change own Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "change_own_biographicalnote" +        } +    }, +    { +        "model": "auth.permission", +        "fields": { +            "name": "Can delete own Biographical note", +            "content_type": [ +                "ishtar_common", +                "biographicalnote" +            ], +            "codename": "delete_own_biographicalnote" +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques : ajout", +            "permissions": [ +                [ +                    "add_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques : lecture", +            "permissions": [ +                [ +                    "view_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques : modification", +            "permissions": [ +                [ +                    "change_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques : suppression", +            "permissions": [ +                [ +                    "delete_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques rattach\u00e9es : ajout", +            "permissions": [ +                [ +                    "add_own_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques rattach\u00e9es : lecture", +            "permissions": [ +                [ +                    "view_own_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques rattach\u00e9es : modification", +            "permissions": [ +                [ +                    "change_own_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    }, +    { +        "model": "auth.group", +        "fields": { +            "name": "Notices biographiques rattach\u00e9es : suppression", +            "permissions": [ +                [ +                    "delete_own_biographicalnote", +                    "ishtar_common", +                    "biographicalnote" +                ] +            ] +        } +    } +] diff --git a/ishtar_common/migrations/0243_default_biographicalnote_permissions.py b/ishtar_common/migrations/0243_default_biographicalnote_permissions.py new file mode 100644 index 000000000..a5399d9a8 --- /dev/null +++ b/ishtar_common/migrations/0243_default_biographicalnote_permissions.py @@ -0,0 +1,32 @@ +# Generated by Django 2.2.24 on 2024-03-25 17:24 + +from django.db import migrations +from ishtar_common.utils import migrations_load_data + +COLOR_WARNING = "\033[93m" +COLOR_ENDC = "\033[0m" + + +def load_data(apps, _): +    migrations_load_data("ishtar_common", "0243_default_biographicalnote_permissions.json") +    Group = apps.get_model("auth", "group") +    ProfileType = apps.get_model("ishtar_common", "profiletype") +    q = ProfileType.objects.filter(txt_idx="administrator") +    if q.count(): +        admin = q.all()[0] +        for group in Group.objects.filter(name__icontains="biographique").all(): +            admin.groups.add(group) +    else: +        print(COLOR_WARNING + "** No administrator profile found **" + COLOR_ENDC) +    print(COLOR_WARNING + "** Verify biographical notes permissions in profile **" + COLOR_ENDC) + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('ishtar_common', '0242_import_debug_field'), +    ] + +    operations = [ +        migrations.RunPython(load_data) +    ]
\ No newline at end of file  | 
