2018-06-29 15:45:21 +00:00
|
|
|
# -*- 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'),
|
|
|
|
]
|
|
|
|
|
2018-06-29 17:28:55 +00:00
|
|
|
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()
|
|
|
|
|
2018-06-29 15:45:21 +00:00
|
|
|
|
2018-06-29 15:45:21 +00:00
|
|
|
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',
|
2018-06-30 01:22:46 +00:00
|
|
|
field=models.CharField(help_text="Valeur de l'alias mail", max_length=128, unique=True),
|
2018-06-29 15:45:21 +00:00
|
|
|
),
|
2018-06-29 17:28:55 +00:00
|
|
|
migrations.RunPython(transfer_pseudo, untransfer_pseudo),
|
2018-06-29 15:45:21 +00:00
|
|
|
]
|