mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-23 06:38:40 +02:00
New option to automaticaly remove accounts with mailboxes.
Beware: activating this mode will make domain removal longer. fix #364
This commit is contained in:
@@ -23,6 +23,10 @@ parameters.register_admin("MAILBOX_TYPE", type="list", deflt="maildir",
|
||||
parameters.register_admin("MAILDIR_ROOT", type="string", deflt=".maildir",
|
||||
visible_if="MAILBOX_TYPE=maildir",
|
||||
help=ugettext_lazy("Sub-directory (inside the mailbox) where messages are stored when using the maildir format"))
|
||||
parameters.register_admin(
|
||||
"AUTO_ACCOUNT_REMOVAL", type="list_yesno", deflt="no",
|
||||
help=ugettext_lazy("When a mailbox is removed, also remove the associated account")
|
||||
)
|
||||
parameters.register_admin(
|
||||
"PASSWORD_SCHEME", type="list", deflt="md5crypt",
|
||||
values=[("crypt", "crypt"),
|
||||
|
||||
@@ -558,7 +558,7 @@ class Domain(DatesAware):
|
||||
self.name))
|
||||
return True
|
||||
|
||||
def delete(self, keepdir=False):
|
||||
def delete(self, fromuser, keepdir=False):
|
||||
from modoboa.lib.permissions import ungrant_access_to_object, ungrant_access_to_objects
|
||||
|
||||
if self.domainalias_set.count():
|
||||
@@ -570,6 +570,9 @@ class Domain(DatesAware):
|
||||
if self.alias_set.count():
|
||||
events.raiseEvent("MailboxAliasDelete", self.alias_set.all())
|
||||
ungrant_access_to_objects(self.alias_set.all())
|
||||
if parameters.get_admin("AUTO_ACCOUNT_REMOVAL") == "yes":
|
||||
for account in User.objects.filter(mailbox__domain__name=self.name):
|
||||
account.delete(fromuser, keepdir)
|
||||
events.raiseEvent("DeleteDomain", self)
|
||||
ungrant_access_to_object(self)
|
||||
super(Domain, self).delete()
|
||||
@@ -811,7 +814,7 @@ def mailbox_deleted_handler(sender, **kwargs):
|
||||
alias.mboxes.remove(mb)
|
||||
if alias.mboxes.count() == 0:
|
||||
alias.delete()
|
||||
|
||||
|
||||
class Alias(DatesAware):
|
||||
address = models.CharField(
|
||||
ugettext_lazy('address'), max_length=254,
|
||||
|
||||
@@ -113,6 +113,7 @@ Domains.prototype = {
|
||||
|
||||
$("a[name=deldomain]").confirm({
|
||||
question: gettext("Delete this domain?"),
|
||||
warning: gettext("This operation will remove ALL data associated to this domain."),
|
||||
checkboxes: {keepdir: gettext("Do not delete domain directory")},
|
||||
success_cb: $.proxy(this.reload_listing, this)
|
||||
});
|
||||
|
||||
@@ -153,7 +153,7 @@ def deldomain(request):
|
||||
raise PermDeniedException
|
||||
if mb and mb.domain == dom:
|
||||
raise AdminError(_("You can't delete your own domain"))
|
||||
dom.delete(keepdir=keepdir)
|
||||
dom.delete(request.user, keepdir)
|
||||
|
||||
msg = ungettext("Domain deleted", "Domains deleted", len(selection))
|
||||
return ajax_simple_response({"status" : "ok", "respmsg" : msg})
|
||||
|
||||
Reference in New Issue
Block a user