2017-12-31 12:24:18 +00:00
|
|
|
# -*- 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 = [
|
2019-11-04 16:55:03 +00:00
|
|
|
("auth", "0008_alter_user_username_max_length"),
|
|
|
|
("users", "0061_auto_20171230_2033"),
|
2017-12-31 12:24:18 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
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()
|
2019-11-04 16:55:03 +00:00
|
|
|
grp.name = gr.unix_name
|
2017-12-31 12:24:18 +00:00
|
|
|
grp.save()
|
2019-11-04 16:55:03 +00:00
|
|
|
gr.group_ptr = grp
|
2017-12-31 12:24:18 +00:00
|
|
|
gr.save()
|
|
|
|
|
|
|
|
def delete_groups(apps, schema_editor):
|
|
|
|
group = apps.get_model("auth", "Group")
|
2019-11-04 16:55:03 +00:00
|
|
|
db_alias = schema_editor.connection.alias
|
2017-12-31 12:24:18 +00:00
|
|
|
group.objects.using(db_alias).all().delete()
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RenameField(
|
2019-11-04 16:55:03 +00:00
|
|
|
model_name="listright", old_name="listright", new_name="unix_name"
|
2017-12-31 12:24:18 +00:00
|
|
|
),
|
|
|
|
migrations.AddField(
|
2019-11-04 16:55:03 +00:00
|
|
|
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",
|
|
|
|
),
|
2017-12-31 12:24:18 +00:00
|
|
|
preserve_default=False,
|
|
|
|
),
|
|
|
|
migrations.RunPython(create_groups, delete_groups),
|
|
|
|
]
|