Add catchall info to domain_info output v0.6.x
authormartin f. krafft <madduck@madduck.net>
Tue, 10 Apr 2012 00:08:12 +0200
branchv0.6.x
changeset 510 1fa354bbdb90
parent 509 1a9247e9763f
child 511 0244f1344b04
Add catchall info to domain_info output
VirtualMailManager/cli/subcommands.py
VirtualMailManager/domain.py
VirtualMailManager/handler.py
--- a/VirtualMailManager/cli/subcommands.py	Tue Apr 10 00:07:49 2012 +0200
+++ b/VirtualMailManager/cli/subcommands.py	Tue Apr 10 00:08:12 2012 +0200
@@ -274,7 +274,7 @@
     else:
         details = ctx.args[3].lower()
         if details not in ('accounts', 'aliasdomains', 'aliases', 'full',
-                           'relocated'):
+                           'relocated', 'catchall'):
             usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details,
                   ctx.scmd)
     try:
@@ -308,11 +308,14 @@
                 _print_list(info[1], _(u'aliases'))
             elif details == u'relocated':
                 _print_list(info[1], _(u'relocated users'))
+            elif details == u'catchall':
+                _print_list(info[1], _(u'catch-all destinations'))
             else:
                 _print_list(info[1], _(u'alias domains'))
                 _print_list(info[2], _(u'accounts'))
                 _print_list(info[3], _(u'aliases'))
                 _print_list(info[4], _(u'relocated users'))
+                _print_list(info[5], _(u'catch-all destinations'))
 
 
 def domain_quota(ctx):
--- a/VirtualMailManager/domain.py	Tue Apr 10 00:07:49 2012 +0200
+++ b/VirtualMailManager/domain.py	Tue Apr 10 00:08:12 2012 +0200
@@ -414,6 +414,16 @@
             relocated = [addr((address[0], _dom)) for address in addresses]
         return relocated
 
+    def get_catchall(self):
+        """Returns a list with all catchall e-mail addresses of the domain."""
+        self._chk_state()
+        dbc = self._dbh.cursor()
+        dbc.execute('SELECT DISTINCT destination FROM catchall WHERE gid = %s ORDER '
+                    'BY destination', (self._gid,))
+        addresses = dbc.fetchall()
+        dbc.close()
+        return addresses
+
     def get_aliase_names(self):
         """Returns a list with all alias domain names of the domain."""
         self._chk_state()
--- a/VirtualMailManager/handler.py	Tue Apr 10 00:07:49 2012 +0200
+++ b/VirtualMailManager/handler.py	Tue Apr 10 00:08:12 2012 +0200
@@ -515,7 +515,7 @@
         Domain.get_aliase_names(), Domain.get_aliases() and
         Domain.get_relocated."""
         if details not in [None, 'accounts', 'aliasdomains', 'aliases', 'full',
-                           'relocated']:
+                           'relocated', 'catchall']:
             raise VMMError(_(u"Invalid argument: '%s'") % details,
                            INVALID_ARGUMENT)
         dom = self._get_domain(domainname)
@@ -533,9 +533,11 @@
             return (dominfo, dom.get_aliases())
         elif details == 'relocated':
             return(dominfo, dom.get_relocated())
+        elif details == 'catchall':
+            return(dominfo, dom.get_catchall())
         else:
             return (dominfo, dom.get_aliase_names(), dom.get_accounts(),
-                    dom.get_aliases(), dom.get_relocated())
+                    dom.get_aliases(), dom.get_relocated(), dom.get_catchall())
 
     def aliasdomain_add(self, aliasname, domainname):
         """Adds an alias domain to the domain.