(mailbox) allow to disable mailbox

We send a request to dimail API and change mailbox status to disabled.
A disabled mailbox can no longer be used thus access to webmail
is disabled for user.
This commit is contained in:
Sabrina Demagny
2024-11-22 19:49:27 +01:00
parent 3469764697
commit ccb06b3abf
8 changed files with 147 additions and 15 deletions

View File

@@ -215,17 +215,12 @@ class Mailbox(BaseModel):
def save(self, *args, **kwargs):
"""
Modification is forbidden for now.
Override save function to not allow to create or update mailbox of a disabled domain.
"""
self.full_clean()
if self.domain.status == MailDomainStatusChoices.DISABLED:
raise exceptions.ValidationError(
_("You can't create a mailbox for a disabled domain.")
_("You can't create or update a mailbox for a disabled domain.")
)
if self._state.adding:
return super().save(*args, **kwargs)
# Update is not implemented for now
raise NotImplementedError()
return super().save(*args, **kwargs)