mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -208,7 +208,8 @@ def account_auto_created(user):
|
||||
try:
|
||||
domain = Domain.objects.get(name=domname)
|
||||
except Domain.DoesNotExist:
|
||||
label = check_if_domain_exists(domname)
|
||||
label = check_if_domain_exists(
|
||||
domname, [(DomainAlias, _('domain alias'))])
|
||||
if label is not None:
|
||||
return
|
||||
domain = Domain(name=domname, enabled=True, quota=0)
|
||||
|
||||
@@ -72,7 +72,7 @@ class DomainFormGeneral(forms.ModelForm, DynamicForm):
|
||||
|
||||
cleaned_data = self.cleaned_data
|
||||
name = cleaned_data["name"]
|
||||
label = check_if_domain_exists(name)
|
||||
label = check_if_domain_exists(name, [(DomainAlias, _('domain alias'))])
|
||||
if label is not None:
|
||||
self._errors["name"] = self.error_class(
|
||||
[_("A %s with this name already exists" % unicode(label))]
|
||||
@@ -85,16 +85,14 @@ class DomainFormGeneral(forms.ModelForm, DynamicForm):
|
||||
if cleaned_data[k] == "":
|
||||
del cleaned_data[k]
|
||||
continue
|
||||
for dtype, label in [(Domain, _('domain'))] + dtypes:
|
||||
try:
|
||||
dtype.objects.get(name=cleaned_data[k])
|
||||
except dtype.DoesNotExist:
|
||||
continue
|
||||
label = check_if_domain_exists(
|
||||
cleaned_data[k], [(Domain, _('domain'))])
|
||||
if label is not None:
|
||||
self._errors[k] = self.error_class(
|
||||
[_("A %s with this name already exists" % unicode(label))]
|
||||
)
|
||||
del cleaned_data[k]
|
||||
break
|
||||
|
||||
return cleaned_data
|
||||
|
||||
def update_mailbox_quotas(self, domain):
|
||||
|
||||
@@ -139,7 +139,7 @@ def get_domains(user, domfilter=None, searchquery=None, **extrafilters):
|
||||
return chain(domains, extra_domain_entries)
|
||||
|
||||
|
||||
def check_if_domain_exists(name):
|
||||
def check_if_domain_exists(name, extra_checks=None):
|
||||
"""Check if a domain already exists.
|
||||
|
||||
We not only look for domains, we also look for every object that
|
||||
@@ -147,7 +147,9 @@ def check_if_domain_exists(name):
|
||||
|
||||
"""
|
||||
dtypes = events.raiseQueryEvent('CheckDomainName')
|
||||
for dtype, label in [(DomainAlias, _('domain alias'))] + dtypes:
|
||||
if extra_checks is not None:
|
||||
dtypes = extra_checks + dtypes
|
||||
for dtype, label in dtypes:
|
||||
try:
|
||||
dtype.objects.get(name=name)
|
||||
except dtype.DoesNotExist:
|
||||
|
||||
Reference in New Issue
Block a user