🗃️(mailbox_manager) add organization to domain
To be able to provide a SIRET in the ProConnect IdP process we need to be able to link a mail domain to its organization. For now this is not mandatory, as we can't detect the organization and need a frontend process to clarify it.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.1.5 on 2025-02-10 11:10
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0010_team_depth_team_numchild_team_path_and_more'),
|
||||
('mailbox_manager', '0017_alter_maildomain_status'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='maildomain',
|
||||
name='organization',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='mail_domains', to='core.organization'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.1.5 on 2025-02-10 11:10
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0010_team_depth_team_numchild_team_path_and_more'),
|
||||
('mailbox_manager', '0021_maildomain_expected_config'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='maildomain',
|
||||
name='organization',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='mail_domains', to='core.organization'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,52 @@
|
||||
# Generated by Django 5.1.5 on 2025-02-07 16:13
|
||||
|
||||
import django.db.models.functions.text
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def fill_dn_email(apps, schema_editor):
|
||||
"""Fill the dn_email field with the email field."""
|
||||
Mailbox = apps.get_model("mailbox_manager", "Mailbox")
|
||||
|
||||
for mailbox in Mailbox.objects.select_related("domain").filter(
|
||||
models.Q(dn_email="") | models.Q(dn_email__isnull=True)
|
||||
):
|
||||
# quite naive but we don't have many data
|
||||
mailbox.dn_email = mailbox.get_email()
|
||||
mailbox.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mailbox_manager', '0020_maildomain_organization'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mailbox',
|
||||
name='last_login',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='last login'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mailbox',
|
||||
name='password',
|
||||
field=models.CharField(default='', max_length=128, verbose_name='password'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mailbox',
|
||||
name='dn_email',
|
||||
field=models.EmailField(blank=True, editable=False, max_length=254, null=True, unique=True,
|
||||
verbose_name='email'),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=fill_dn_email,
|
||||
reverse_code=migrations.RunPython.noop,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='mailbox',
|
||||
name='dn_email',
|
||||
field=models.EmailField(blank=True, editable=False, max_length=254, unique=True, verbose_name='email'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user