blob: 1bca24ed2637462229e4629cd35683b157556b2c (
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
32
33
 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-11-22 22:17
from __future__ import unicode_literals
from django.db import migrations
def migrate_perm(apps, schema_editor):
    Permission = apps.get_model('auth', 'Permission')
    Group = apps.get_model('auth', 'Group')
    for perm in Permission.objects.filter(
            codename__icontains='filetreatment').exclude(
            codename__icontains='source').all():
        new_codename = perm.codename.replace('filetreatment', 'treatmentfile')
        q = Permission.objects.filter(
            codename=new_codename).exclude(pk=perm.pk)
        for old in list(q.all()):
            for gp in Group.objects.filter(permissions=old):
                gp.permissions.add(perm)
            old.delete()
        perm.codename = new_codename
        perm.save()
class Migration(migrations.Migration):
    dependencies = [
        ('ishtar_common', '0075_auto_20181108_1908'),
    ]
    operations = [
        migrations.RunPython(migrate_perm)
    ]
 |