mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.10.7 on 2018-06-29 15:17
|
|
from __future__ import unicode_literals
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('users', '0073_auto_20180629_1614'),
|
|
]
|
|
|
|
def transfer_pseudo(apps, schema_editor):
|
|
db_alias = schema_editor.connection.alias
|
|
users = apps.get_model("users", "User")
|
|
mailalias = apps.get_model("users", "MailAlias")
|
|
users_list = users.objects.using(db_alias).all()
|
|
for user in users_list:
|
|
mailalias.objects.using(db_alias).create(valeur=user.pseudo, user=user)
|
|
|
|
def untransfer_pseudo(apps, schema_editor):
|
|
db_alias = schema_editor.connection.alias
|
|
mailalias = apps.get_model("users", "MailAlias")
|
|
mailalias.objects.using(db_alias).delete()
|
|
|
|
|
|
operations = [
|
|
migrations.AlterField(
|
|
model_name='mailalias',
|
|
name='user',
|
|
field=models.ForeignKey(help_text='Utilisateur associé', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
|
),
|
|
migrations.AlterField(
|
|
model_name='mailalias',
|
|
name='valeur',
|
|
field=models.CharField(help_text="Valeur de l'alias mail", max_length=128, unique=True),
|
|
),
|
|
migrations.RunPython(transfer_pseudo, untransfer_pseudo),
|
|
]
|