mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -232,7 +232,13 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
|
||||
def clean_email(self):
|
||||
"""Ensure lower case emails"""
|
||||
return self.cleaned_data["email"].lower()
|
||||
email = self.cleaned_data["email"].lower()
|
||||
self.locpart, domname = split_mailbox(email)
|
||||
try:
|
||||
self.domain = Domain.objects.get(name=domname)
|
||||
except Domain.DoesNotExist:
|
||||
raise forms.ValidationError(_("Domain does not exist"))
|
||||
return email
|
||||
|
||||
def clean(self):
|
||||
"""Custom fields validation.
|
||||
@@ -248,16 +254,12 @@ class AccountFormMail(forms.Form, DynamicForm):
|
||||
|
||||
def create_mailbox(self, user, account):
|
||||
"""Create a mailbox associated to :kw:`account`."""
|
||||
locpart, domname = split_mailbox(self.cleaned_data["email"])
|
||||
try:
|
||||
domain = Domain.objects.get(name=domname)
|
||||
except Domain.DoesNotExist:
|
||||
raise NotFound(_("Domain does not exist"))
|
||||
if not user.can_access(domain):
|
||||
if not user.can_access(self.domain):
|
||||
raise PermDeniedException
|
||||
events.raiseEvent("CanCreate", user, "mailboxes")
|
||||
self.mb = Mailbox(address=locpart, domain=domain, user=account,
|
||||
use_domain_quota=self.cleaned_data["quota_act"])
|
||||
self.mb = Mailbox(
|
||||
address=self.locpart, domain=self.domain, user=account,
|
||||
use_domain_quota=self.cleaned_data["quota_act"])
|
||||
self.mb.set_quota(self.cleaned_data["quota"],
|
||||
user.has_perm("admin.add_domain"))
|
||||
self.mb.save(creator=user)
|
||||
|
||||
@@ -16,7 +16,7 @@ from modoboa.lib.web_utils import render_to_json_response
|
||||
|
||||
from ..lib import check_if_domain_exists
|
||||
from ..models import (
|
||||
Domain, DomainAlias, Mailbox, Alias, Quota
|
||||
Domain, DomainAlias, Mailbox, Alias
|
||||
)
|
||||
|
||||
DOMAIN_TYPES = [
|
||||
|
||||
Reference in New Issue
Block a user