summaryrefslogtreecommitdiff
path: root/ishtar_common/migrations/0043_add_import_group.py
blob: 1587dcff1ca97f7190a592eb2762c9c39c5690a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-04-12 17:51
from __future__ import unicode_literals

from django.db import migrations


def add_import_group(apps, schema_editor):
    Group = apps.get_model('auth', 'Group')
    ProfileType = apps.get_model('ishtar_common', 'ProfileType')
    gp, created = Group.objects.get_or_create(
        name="Import : ajout/modification/suppression")
    pt, created = ProfileType.objects.get_or_create(
        txt_idx="administrator",
        defaults={
            'label':"Administrateur", 'comment': "", 'available':True
        }
    )
    if gp.pk not in list([g.pk for g in pt.groups.all()]):
        pt.groups.add(gp)


class Migration(migrations.Migration):

    dependencies = [
        ('ishtar_common', '0042_remove_persontype_groups'),
    ]

    operations = [
        migrations.RunPython(add_import_group),
    ]