8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 20:03:11 +00:00
re2o/users/migrations/0074_transfermail.py

36 lines
973 B
Python

# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-06-26 18:34
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0073_mail_mailalias'),
]
def create_mail(apps, schema_editor):
db_alias = schema_editor.connection.alias
user = apps.get_model('users','User')
mail = apps.get_model('users','Mail')
mailalias = apps.get_model('users','MailAlias')
users = user.objects.using(db_alias).all()
for us in users:
ma = mail()
ma.user=us
ma.external_mail = us.email
ma.save()
al = mailalias()
al.mail = ma
al.valeur = us.pseudo
al.save()
def uncreatemail(apps,schema_editor):
pass
operations = [
migrations.RunPython(create_mail, uncreatemail)
]