Few fixes.

fix #603
This commit is contained in:
Antoine Nguyen
2014-09-17 14:42:02 +02:00
parent 888632d8f3
commit 70e953de75
2 changed files with 5 additions and 5 deletions
@@ -180,6 +180,7 @@ class AccountFormMail(forms.Form, DynamicForm):
return self.cleaned_data
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)
+4 -5
View File
@@ -184,9 +184,9 @@ class Mailbox(AdminObject):
"""
old_mail_home = self.mail_home
old_qvalue = self.quota_value
self.address = address
self.domain = domain
old_qvalue = self.quota_value
self.quota_value = Quota.objects.create(
username=self.full_address, bytes=old_qvalue.bytes,
messages=old_qvalue.messages
@@ -218,7 +218,8 @@ class Mailbox(AdminObject):
self.quota = 0
elif int(value) > self.domain.quota and not override_rules:
raise BadRequest(
_("Quota is greater than the allowed domain's limit (%dM)" % self.domain.quota)
_("Quota is greater than the allowed domain's limit (%dM)"
% self.domain.quota)
)
else:
self.quota = value
@@ -261,9 +262,7 @@ class Mailbox(AdminObject):
We just make sure a quota record is defined for this mailbox.
"""
try:
q = self.quota_value
except Quota.DoesNotExist:
if self.quota_value is None:
self.quota_value, created = Quota.objects.get_or_create(
username=self.full_address)
super(Mailbox, self).save(*args, **kwargs)