622 if destination.gid and \ |
622 if destination.gid and \ |
623 not self._chk_other_address_types(destination, TYPE_RELOCATED): |
623 not self._chk_other_address_types(destination, TYPE_RELOCATED): |
624 self._warnings.append(_("The destination account/alias '%s' " |
624 self._warnings.append(_("The destination account/alias '%s' " |
625 "does not exist.") % destination) |
625 "does not exist.") % destination) |
626 |
626 |
627 def user_delete(self, emailaddress, force=False): |
627 def user_delete(self, emailaddress, delete_home, force=False): |
628 """Wrapper around Account.delete(...)""" |
628 """Wrapper around Account.delete(...)""" |
|
629 if not isinstance(delete_home, bool): |
|
630 raise TypeError('delete_home must be a bool') |
629 if not isinstance(force, bool): |
631 if not isinstance(force, bool): |
630 raise TypeError('force must be a bool') |
632 raise TypeError('force must be a bool') |
631 acc = self._get_account(emailaddress) |
633 acc = self._get_account(emailaddress) |
632 if not acc: |
634 if not acc: |
633 raise VMMError(_("The account '%s' does not exist.") % |
635 raise VMMError(_("The account '%s' does not exist.") % |
635 uid = acc.uid |
637 uid = acc.uid |
636 gid = acc.gid |
638 gid = acc.gid |
637 dom_dir = acc.domain.directory |
639 dom_dir = acc.domain.directory |
638 acc_dir = acc.home |
640 acc_dir = acc.home |
639 acc.delete(force) |
641 acc.delete(force) |
640 if self._cfg.dget('account.delete_directory'): |
642 if delete_home or self._cfg.dget('account.delete_directory'): |
641 try: |
643 try: |
642 self._delete_home(dom_dir, uid, gid) |
644 self._delete_home(dom_dir, uid, gid) |
643 except VMMError as err: |
645 except VMMError as err: |
644 if err.code in (FOUND_DOTS_IN_PATH, MAILDIR_PERM_MISMATCH, |
646 if err.code in (FOUND_DOTS_IN_PATH, MAILDIR_PERM_MISMATCH, |
645 NO_SUCH_DIRECTORY): |
647 NO_SUCH_DIRECTORY): |