Simple protections added.

see #391
This commit is contained in:
Antoine Nguyen
2013-04-13 10:15:54 +02:00
parent bcb2bc36f2
commit 15ab1c46df
2 changed files with 18 additions and 4 deletions
+16 -2
View File
@@ -555,6 +555,7 @@ class Domain(DatesAware):
events.raiseEvent("DomainAliasDeleted", self.domainalias_set.all())
ungrant_access_to_objects(self.domainalias_set.all())
if self.mailbox_set.count():
Quota.objects.filter(username__contains='@%s' % self.name).delete()
events.raiseEvent("DeleteMailbox", self.mailbox_set.all())
ungrant_access_to_objects(self.mailbox_set.all())
hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
@@ -724,6 +725,8 @@ class Mailbox(DatesAware):
self.quota = value
def get_cur_quota(self):
if not self.quota:
return 0
q = Quota.objects.get(username=self.full_address)
return q.bytes / (self.quota * 1048576) * 100
@@ -743,8 +746,19 @@ class Mailbox(DatesAware):
Quota.objects.create(username=self.full_address)
def delete(self, keepdir=False):
q = Quota.objects.get(username=self.full_address)
q.delete()
"""Custom delete method
We try to delete the associated quota in the same time (it may
has already been removed if we're deleting a domain).
:param bool keepdir: delete the mailbox home dir on the filesystem or not
"""
try:
q = Quota.objects.get(username=self.full_address)
except Quota.DoesNotExist:
pass
else:
q.delete()
super(Mailbox, self).delete()
if not keepdir:
self.delete_dir()
+2 -2
View File
@@ -122,13 +122,13 @@ Domains.prototype = {
var deloptions = (data.handle_mailboxes)
? {keepdir: gettext("Do not delete domain directory")}
: {};
var warnmsg = (data.auto_account_removal)
var warnmsg = (data.auto_account_removal && data.auto_account_removal == "yes")
? gettext("This operation will remove ALL data associated to this domain.")
: gettext("This operation will remove all data associated to this domain, excepting accounts.");
$("a[name=deldomain]").confirm({
question: gettext("Delete this domain?"),
warning: gettext("This operation will remove ALL data associated to this domain."),
warning: warnmsg,
checkboxes: deloptions,
success_cb: $.proxy(this.reload_listing, this)
});