mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -2,10 +2,11 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from param_tools import tools as param_tools
|
||||
from modoboa.parameters import tools as param_tools
|
||||
from modoboa.lib.sysutils import exec_cmd
|
||||
from modoboa.lib.exceptions import InternalError
|
||||
|
||||
@@ -52,13 +53,16 @@ class Command(BaseCommand):
|
||||
raise OperationError(output)
|
||||
|
||||
def delete_mailbox(self, operation):
|
||||
"""Try to delete a mailbox tree on filesystem."""
|
||||
if not os.path.exists(operation.argument):
|
||||
return
|
||||
code, output = exec_cmd(
|
||||
"rm -r %s" % operation.argument
|
||||
)
|
||||
if code:
|
||||
raise OperationError(output)
|
||||
|
||||
def onerror(function, path, excinfo):
|
||||
"""Handle errors."""
|
||||
self.logger.critical(
|
||||
"delete failed (reason: {})".format(excinfo))
|
||||
|
||||
shutil.rmtree(operation.argument, False, onerror)
|
||||
|
||||
def check_pidfile(self, path):
|
||||
"""Check if this command is already running
|
||||
|
||||
@@ -226,8 +226,7 @@ class Domain(AdminObject):
|
||||
if self.alias_set.count():
|
||||
ungrant_access_to_objects(self.alias_set.all())
|
||||
if param_tools.get_global_parameter("auto_account_removal"):
|
||||
for account in User.objects.filter(mailbox__domain=self):
|
||||
account.delete(fromuser, keepdir)
|
||||
User.objects.filter(mailbox__domain=self).delete()
|
||||
elif self.mailbox_set.count():
|
||||
Quota.objects.filter(username__contains="@%s" % self.name).delete()
|
||||
ungrant_access_to_objects(self.mailbox_set.all())
|
||||
|
||||
@@ -135,7 +135,7 @@ def editdomain(request, dom_id):
|
||||
@login_required
|
||||
@permission_required("admin.delete_domain")
|
||||
def deldomain(request, dom_id):
|
||||
keepdir = True if request.POST.get("keepdir", "false") == "true" else False
|
||||
keepdir = request.POST.get("keepdir", "false") == "true"
|
||||
try:
|
||||
mb = Mailbox.objects.get(user__id=request.user.id)
|
||||
except Mailbox.DoesNotExist:
|
||||
|
||||
Reference in New Issue
Block a user