summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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
commit32d21682f4dcbb62e43ba119904ec4adfac1cefc (patch)
tree0c74210864a0cde9994e4ff9445064b1c019ba82
parent3cdfbce31e5ad0a33572b0f8393a8ba36a88c7e1 (diff)
downloadIshtar-32d21682f4dcbb62e43ba119904ec4adfac1cefc.tar.bz2
Ishtar-32d21682f4dcbb62e43ba119904ec4adfac1cefc.zip
Profile migration: fix import content_type creation
-rw-r--r--ishtar_common/management/commands/import_access_controls.py1
-rw-r--r--ishtar_common/migrations/0044_add_import_group.py11
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(