mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-01 07:32:47 +00:00
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# Generated by Django 1.10.7 on 2017-12-30 23:56
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
from django.db import migrations, models
|
||
|
import django.db.models.deletion
|
||
|
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
|
('auth', '0008_alter_user_username_max_length'),
|
||
|
('users', '0061_auto_20171230_2033'),
|
||
|
]
|
||
|
|
||
|
def create_groups(apps, schema_editor):
|
||
|
group = apps.get_model("auth", "Group")
|
||
|
listrights = apps.get_model("users", "ListRight")
|
||
|
db_alias = schema_editor.connection.alias
|
||
|
for gr in listrights.objects.using(db_alias).all():
|
||
|
grp = group()
|
||
|
grp.name=gr.unix_name
|
||
|
grp.save()
|
||
|
gr.group_ptr=grp
|
||
|
gr.save()
|
||
|
|
||
|
def delete_groups(apps, schema_editor):
|
||
|
group = apps.get_model("auth", "Group")
|
||
|
db_alias = schema_editor.connection.alias
|
||
|
group.objects.using(db_alias).all().delete()
|
||
|
|
||
|
operations = [
|
||
|
migrations.RenameField(
|
||
|
model_name='listright',
|
||
|
old_name='listright',
|
||
|
new_name='unix_name',
|
||
|
),
|
||
|
migrations.AddField(
|
||
|
model_name='listright',
|
||
|
name='group_ptr',
|
||
|
field=models.OneToOneField(blank=True, null=True, auto_created=True, on_delete=django.db.models.deletion.CASCADE, serialize=False, to='auth.Group'),
|
||
|
preserve_default=False,
|
||
|
),
|
||
|
migrations.RunPython(create_groups, delete_groups),
|
||
|
]
|