2017-09-26 22:18:39 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
|
|
|
|
|
|
def existing_groups(apps, schema_editor):
|
2019-01-14 22:41:38 +01:00
|
|
|
Group = apps.get_model("auth", "Group")
|
|
|
|
KFetGroup = apps.get_model("kfetauth", "Group")
|
2017-09-26 22:18:39 +02:00
|
|
|
|
2019-01-14 22:41:38 +01:00
|
|
|
for group in Group.objects.filter(name__icontains="K-Fêt"):
|
2017-09-26 22:18:39 +02:00
|
|
|
kf_group = KFetGroup(group_ptr=group, pk=group.pk, name=group.name)
|
|
|
|
kf_group.save()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
"""
|
|
|
|
Data migration.
|
|
|
|
|
|
|
|
Previously, K-Fêt groups were identified with the presence of 'K-Fêt' in
|
|
|
|
their name.
|
|
|
|
"""
|
|
|
|
|
2019-01-14 22:41:38 +01:00
|
|
|
dependencies = [("kfetauth", "0002_local_group_and_perm")]
|
2017-09-26 22:18:39 +02:00
|
|
|
|
2019-01-14 22:41:38 +01:00
|
|
|
operations = [migrations.RunPython(existing_groups)]
|