diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-29 15:47:49 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:49:36 +0200 | 
| commit | c1184813290d639b4a58c952733141e59e45ffe5 (patch) | |
| tree | 0c74210864a0cde9994e4ff9445064b1c019ba82 | |
| parent | 77f89249b1ea0cad24bc6a545188d6fd39b125df (diff) | |
| download | Ishtar-c1184813290d639b4a58c952733141e59e45ffe5.tar.bz2 Ishtar-c1184813290d639b4a58c952733141e59e45ffe5.zip  | |
Profile migration: fix import content_type creation
| -rw-r--r-- | ishtar_common/management/commands/import_access_controls.py | 1 | ||||
| -rw-r--r-- | ishtar_common/migrations/0044_add_import_group.py | 11 | 
2 files changed, 10 insertions, 2 deletions
diff --git a/ishtar_common/management/commands/import_access_controls.py b/ishtar_common/management/commands/import_access_controls.py index 62692485d..c13f41731 100644 --- a/ishtar_common/management/commands/import_access_controls.py +++ b/ishtar_common/management/commands/import_access_controls.py @@ -26,6 +26,7 @@ from django.contrib.contenttypes.models import ContentType  from ishtar_common.models import PersonType +  class Command(BaseCommand):      args = '<access control file>'      help = 'Import access controls' diff --git a/ishtar_common/migrations/0044_add_import_group.py b/ishtar_common/migrations/0044_add_import_group.py index bff5442ac..8ff5117b4 100644 --- a/ishtar_common/migrations/0044_add_import_group.py +++ b/ishtar_common/migrations/0044_add_import_group.py @@ -7,13 +7,20 @@ from django.db import migrations  def add_import_group(apps, schema_editor):      Group = apps.get_model('auth', 'Group') +    ContentType = apps.get_model('contenttypes', 'ContentType')      ProfileType = apps.get_model('ishtar_common', 'ProfileType')      Permission = apps.get_model('auth', 'Permission')      gp, created = Group.objects.get_or_create(          name="Import : ajout/modification/suppression") -    for perm in ['add_import', 'change_import', 'delete_import']: -        p = Permission.objects.get(codename=perm) +    content_type, created = ContentType.objects.get_or_create( +        model='import', app_label='ishtar_common') + +    for perm, name in (('add_import', "Can add Import"), +                       ('change_import', "Can change Import"), +                       ('delete_import', "Can delete Import")): +        p, created = Permission.objects.get_or_create( +            codename=perm, name=name, content_type=content_type)          gp.permissions.add(p)      pt, created = ProfileType.objects.get_or_create(  | 
