diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-01-23 16:23:10 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-01-28 14:52:09 +0100 |
| commit | 9bca2db98069a01bb2e991887993d578da6d6e62 (patch) | |
| tree | b4a1c9bd54ee397fcc4708e45d49f212967446c5 /ishtar_common/migrations | |
| parent | c9849f27ecf4073adfe319645e40c6e60ce385c5 (diff) | |
| download | Ishtar-9bca2db98069a01bb2e991887993d578da6d6e62.tar.bz2 Ishtar-9bca2db98069a01bb2e991887993d578da6d6e62.zip | |
🐛 fix permission migration
Diffstat (limited to 'ishtar_common/migrations')
| -rw-r--r-- | ishtar_common/migrations/0274_import_gis_options.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/ishtar_common/migrations/0274_import_gis_options.py b/ishtar_common/migrations/0274_import_gis_options.py index b7e93030b..553f2fb83 100644 --- a/ishtar_common/migrations/0274_import_gis_options.py +++ b/ishtar_common/migrations/0274_import_gis_options.py @@ -1,25 +1,34 @@ # Generated by Django 4.2.19 on 2026-01-21 14:08 -from django.db import migrations, models -import django.db.models.deletion +from django.db import migrations +from django.utils.translation import gettext_lazy as _ def update_groups(apps, __): Permission = apps.get_model("auth", "Permission") Group = apps.get_model("auth", "Group") + ContentType = apps.get_model("contenttypes", "ContentType") + ct = ContentType.objects.get(app_label='ishtar_common', model='import') update = ( - ("Imports : lecture", "view_gis_import"), - ("Imports rattachés : lecture", "view_own_gis_import"), - ("Imports : ajout", "change_gis_import"), + ("Imports : lecture", "view_gis_import", _("Can export to QGIS")), + ("Imports rattachés : lecture", "view_own_gis_import", _("Can export own to QGIS")), + ("Imports : ajout", "change_gis_import", _("Can create import from QGIS")), ) - for gp_name, codename in update: + for gp_name, codename, p_name 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) + else: + perm = Permission.objects.create( + codename=codename, + name=p_name, + content_type=ct + ) + + gp = gp.all()[0] + gp.permissions.add(perm) class Migration(migrations.Migration): |
