mirror of https://gitlab.federez.net/re2o/re2o
committed by
Maël Kervella
11 changed files with 134 additions and 42 deletions
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-06-26 19:31 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('preferences', '0034_auto_20180416_1120'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='optionaluser', |
||||
|
name='mail_extension', |
||||
|
field=models.CharField(default='@example.org', help_text='Extension principale pour les mails internes', max_length=32), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,38 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-06-26 19:07 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.conf import settings |
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
import re2o.mixins |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('users', '0072_auto_20180426_2021'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='Mail', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('external_mail', models.EmailField(help_text='Mail externe', max_length=254)), |
||||
|
('redirection', models.BooleanField(default=False)), |
||||
|
('internal_address', models.BooleanField(default=False)), |
||||
|
('user', models.OneToOneField(help_text="Object mail d'un User", on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), |
||||
|
], |
||||
|
bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model), |
||||
|
), |
||||
|
migrations.CreateModel( |
||||
|
name='MailAlias', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('valeur', models.CharField(help_text="username de l'adresse mail", max_length=64, unique=True)), |
||||
|
('mail', models.ForeignKey(help_text='Objects Mail associé', on_delete=django.db.models.deletion.CASCADE, to='users.Mail')), |
||||
|
], |
||||
|
bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,36 @@ |
|||||
|
# -*- 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) |
||||
|
] |
||||
Loading…
Reference in new issue