✨(domains) add support email field on MailDomain
Add new field on MailDomain to allow contact support if some actions are required to fix domain.
This commit is contained in:
@@ -8,6 +8,10 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- ✨(domains) add support email field on domain
|
||||||
|
|
||||||
## [1.11.0] - 2025-02-07
|
## [1.11.0] - 2025-02-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class MailDomainSerializer(serializers.ModelSerializer):
|
|||||||
"created_at",
|
"created_at",
|
||||||
"updated_at",
|
"updated_at",
|
||||||
"count_mailboxes",
|
"count_mailboxes",
|
||||||
|
"support_email",
|
||||||
]
|
]
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
"id",
|
"id",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class MailDomainViewSet(
|
|||||||
|
|
||||||
POST /api/<version>/mail-domains/ with expected data:
|
POST /api/<version>/mail-domains/ with expected data:
|
||||||
- name: str
|
- name: str
|
||||||
|
- support_email: str
|
||||||
Return newly created domain
|
Return newly created domain
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class MailDomainFactory(factory.django.DjangoModelFactory):
|
|||||||
|
|
||||||
name = factory.Faker("domain_name")
|
name = factory.Faker("domain_name")
|
||||||
slug = factory.LazyAttribute(lambda o: slugify(o.name))
|
slug = factory.LazyAttribute(lambda o: slugify(o.name))
|
||||||
|
support_email = factory.Faker("email")
|
||||||
|
|
||||||
@factory.post_generation
|
@factory.post_generation
|
||||||
def users(self, create, extracted, **kwargs):
|
def users(self, create, extracted, **kwargs):
|
||||||
|
|||||||
@@ -66,7 +66,11 @@ class Command(BaseCommand):
|
|||||||
# we create a domain and add John Doe to it
|
# we create a domain and add John Doe to it
|
||||||
domain_name = "test.domain.com"
|
domain_name = "test.domain.com"
|
||||||
domain = MailDomain.objects.get_or_create(
|
domain = MailDomain.objects.get_or_create(
|
||||||
name=domain_name, defaults={"status": enums.MailDomainStatusChoices.ENABLED}
|
name=domain_name,
|
||||||
|
defaults={
|
||||||
|
"status": enums.MailDomainStatusChoices.ENABLED,
|
||||||
|
"support_email": f"support@{domain_name}",
|
||||||
|
},
|
||||||
)[0]
|
)[0]
|
||||||
self.create_domain(domain_name)
|
self.create_domain(domain_name)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Generated by Django 5.1.5 on 2025-02-02 21:49
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def fill_support_email(apps, schema_editor):
|
||||||
|
MailDomain = apps.get_model('mailbox_manager', 'MailDomain')
|
||||||
|
for domain in MailDomain.objects.filter(support_email__isnull=True):
|
||||||
|
domain.support_email = "support-regie@numerique.gouv.fr"
|
||||||
|
domain.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mailbox_manager', '0017_alter_maildomain_status'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='maildomain',
|
||||||
|
name='support_email',
|
||||||
|
field=models.EmailField(blank=True, max_length=254, null=True, verbose_name='support email'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(fill_support_email, reverse_code=migrations.RunPython.noop),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='maildomain',
|
||||||
|
name='support_email',
|
||||||
|
field=models.EmailField(max_length=254, verbose_name='support email'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -29,6 +29,7 @@ class MailDomain(BaseModel):
|
|||||||
default=MailDomainStatusChoices.PENDING,
|
default=MailDomainStatusChoices.PENDING,
|
||||||
choices=MailDomainStatusChoices.choices,
|
choices=MailDomainStatusChoices.choices,
|
||||||
)
|
)
|
||||||
|
support_email = models.EmailField(_("support email"), null=False, blank=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "people_mail_domain"
|
db_table = "people_mail_domain"
|
||||||
|
|||||||
@@ -99,7 +99,12 @@ def test_api_mail_domains__create_authenticated():
|
|||||||
)
|
)
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/api/v1.0/mail-domains/",
|
"/api/v1.0/mail-domains/",
|
||||||
{"name": domain_name, "context": "null", "features": ["webmail"]},
|
{
|
||||||
|
"name": domain_name,
|
||||||
|
"context": "null",
|
||||||
|
"features": ["webmail"],
|
||||||
|
"support_email": f"support@{domain_name}",
|
||||||
|
},
|
||||||
format="json",
|
format="json",
|
||||||
)
|
)
|
||||||
assert response.status_code == status.HTTP_201_CREATED
|
assert response.status_code == status.HTTP_201_CREATED
|
||||||
@@ -115,6 +120,7 @@ def test_api_mail_domains__create_authenticated():
|
|||||||
"updated_at": domain.updated_at.isoformat().replace("+00:00", "Z"),
|
"updated_at": domain.updated_at.isoformat().replace("+00:00", "Z"),
|
||||||
"abilities": domain.get_abilities(user),
|
"abilities": domain.get_abilities(user),
|
||||||
"count_mailboxes": 0,
|
"count_mailboxes": 0,
|
||||||
|
"support_email": domain.support_email,
|
||||||
}
|
}
|
||||||
|
|
||||||
# a new domain with status "pending" is created and authenticated user is the owner
|
# a new domain with status "pending" is created and authenticated user is the owner
|
||||||
@@ -171,10 +177,14 @@ def test_api_mail_domains__create_authenticated__dimail_failure():
|
|||||||
)
|
)
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/api/v1.0/mail-domains/",
|
"/api/v1.0/mail-domains/",
|
||||||
{"name": domain_name, "context": "null", "features": ["webmail"]},
|
{
|
||||||
|
"name": domain_name,
|
||||||
|
"context": "null",
|
||||||
|
"features": ["webmail"],
|
||||||
|
"support_email": f"support@{domain_name}",
|
||||||
|
},
|
||||||
format="json",
|
format="json",
|
||||||
)
|
)
|
||||||
assert response.status_code == status.HTTP_201_CREATED
|
|
||||||
domain = models.MailDomain.objects.get()
|
domain = models.MailDomain.objects.get()
|
||||||
|
|
||||||
# response is as expected
|
# response is as expected
|
||||||
@@ -187,6 +197,7 @@ def test_api_mail_domains__create_authenticated__dimail_failure():
|
|||||||
"updated_at": domain.updated_at.isoformat().replace("+00:00", "Z"),
|
"updated_at": domain.updated_at.isoformat().replace("+00:00", "Z"),
|
||||||
"abilities": domain.get_abilities(user),
|
"abilities": domain.get_abilities(user),
|
||||||
"count_mailboxes": 0,
|
"count_mailboxes": 0,
|
||||||
|
"support_email": domain.support_email,
|
||||||
}
|
}
|
||||||
|
|
||||||
# a new domain with status "failed" is created and authenticated user is the owner
|
# a new domain with status "failed" is created and authenticated user is the owner
|
||||||
@@ -244,6 +255,7 @@ def test_api_mail_domains__create_dimail_domain(caplog):
|
|||||||
"/api/v1.0/mail-domains/",
|
"/api/v1.0/mail-domains/",
|
||||||
{
|
{
|
||||||
"name": domain_name,
|
"name": domain_name,
|
||||||
|
"support_email": f"support@{domain_name}",
|
||||||
},
|
},
|
||||||
format="json",
|
format="json",
|
||||||
)
|
)
|
||||||
@@ -292,6 +304,7 @@ def test_api_mail_domains__no_creation_when_dimail_duplicate(caplog):
|
|||||||
"/api/v1.0/mail-domains/",
|
"/api/v1.0/mail-domains/",
|
||||||
{
|
{
|
||||||
"name": domain_name,
|
"name": domain_name,
|
||||||
|
"support_email": f"support@{domain_name}",
|
||||||
},
|
},
|
||||||
format="json",
|
format="json",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -87,4 +87,5 @@ def test_api_mail_domains__retrieve_authenticated_related():
|
|||||||
"updated_at": domain.updated_at.isoformat().replace("+00:00", "Z"),
|
"updated_at": domain.updated_at.isoformat().replace("+00:00", "Z"),
|
||||||
"abilities": domain.get_abilities(user),
|
"abilities": domain.get_abilities(user),
|
||||||
"count_mailboxes": 10,
|
"count_mailboxes": 10,
|
||||||
|
"support_email": domain.support_email,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user