blob: 4edef4a4491e84fb6b7739046142c6c661adc270 (
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)
if q.count():
for gp in Group.objects.filter(permissions=q.all()[0]):
gp.permissions.add(perm)
q.all()[0].delete()
perm.codename = new_codename
perm.save()
class Migration(migrations.Migration):
dependencies = [
('ishtar_common', '0075_auto_20181108_1908'),
]
operations = [
migrations.RunPython(migrate_perm)
]
|