diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-01-21 12:34:57 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-01-21 17:05:17 +0100 |
| commit | 3bd682b730198c69f76366ef456893c9d2b68fb3 (patch) | |
| tree | 9f8d94bb4c66787977392b565ba901373b1b3e51 /ishtar_common/migrations | |
| parent | f627155f8d6a5505477d1cc52109356a1cfa4c24 (diff) | |
| download | Ishtar-3bd682b730198c69f76366ef456893c9d2b68fb3.tar.bz2 Ishtar-3bd682b730198c69f76366ef456893c9d2b68fb3.zip | |
🐛 GIS API: fix permissions - improve regenerate permissions
Diffstat (limited to 'ishtar_common/migrations')
| -rw-r--r-- | ishtar_common/migrations/0274_import_gis_options.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ishtar_common/migrations/0274_import_gis_options.py b/ishtar_common/migrations/0274_import_gis_options.py new file mode 100644 index 000000000..b7e93030b --- /dev/null +++ b/ishtar_common/migrations/0274_import_gis_options.py @@ -0,0 +1,37 @@ +# Generated by Django 4.2.19 on 2026-01-21 14:08 + +from django.db import migrations, models +import django.db.models.deletion + + +def update_groups(apps, __): + Permission = apps.get_model("auth", "Permission") + Group = apps.get_model("auth", "Group") + update = ( + ("Imports : lecture", "view_gis_import"), + ("Imports rattachés : lecture", "view_own_gis_import"), + ("Imports : ajout", "change_gis_import"), + ) + for gp_name, codename in update: + gp = Group.objects.filter(name=gp_name) + if gp.exists(): + perm = Permission.objects.filter(codename=codename) + if perm.exists(): + gp = gp.all()[0] + perm = perm.all()[0] + gp.permissions.add(perm) + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0273_importertype_gis_type'), + ] + + operations = [ + migrations.AlterModelOptions( + name='import', + options={'permissions': (('view_own_import', 'Can view own Import'), ('add_own_import', 'Can add own Import'), ('change_own_import', 'Can change own Import'), ('delete_own_import', 'Can delete own Import'), ('view_gis_import', 'Can export to QGIS'), ('view_own_gis_import', 'Can export own to QGIS'), ('change_gis_import', 'Can import from QGIS'), ('change_own_gis_import', 'Can import own to QGIS')), 'verbose_name': 'Import - Import', 'verbose_name_plural': 'Import - Imports'}, + ), + migrations.RunPython(update_groups) + ] |
