mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
+16
-2
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user