VirtualMailManager/AliasDomain.py
changeset 155 eb866ebb9f2e
parent 138 617f27715b01
child 162 0ac9ef587769
equal deleted inserted replaced
154:6e6488722807 155:eb866ebb9f2e
    33     def save(self):
    33     def save(self):
    34         if self.__gid > 0:
    34         if self.__gid > 0:
    35             raise VADE(_(u'The alias domain “%s” already exists.') %self.__name,
    35             raise VADE(_(u'The alias domain “%s” already exists.') %self.__name,
    36                     ERR.ALIASDOMAIN_EXISTS)
    36                     ERR.ALIASDOMAIN_EXISTS)
    37         if self._domain is None:
    37         if self._domain is None:
    38             raise VADE(_(u'No destination domain for alias domain denoted.'),
    38             raise VADE(_(u'No destination domain specified for alias domain.'),
    39                     ERR.ALIASDOMAIN_NO_DOMDEST)
    39                     ERR.ALIASDOMAIN_NO_DOMDEST)
    40         if self._domain._id < 1:
    40         if self._domain._id < 1:
    41             raise VADE (_(u"The target domain “%s” doesn't exist yet.") %
    41             raise VADE (_(u"The target domain “%s” doesn't exist.") %
    42                     self._domain._name, ERR.NO_SUCH_DOMAIN)
    42                     self._domain._name, ERR.NO_SUCH_DOMAIN)
    43         dbc = self._dbh.cursor()
    43         dbc = self._dbh.cursor()
    44         dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary)\
    44         dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary)\
    45  VALUES (%s, %s, FALSE)', self.__name, self._domain._id)
    45  VALUES (%s, %s, FALSE)', self.__name, self._domain._id)
    46         self._dbh.commit()
    46         self._dbh.commit()
    58             else:# an almost unlikely case, isn't it?
    58             else:# an almost unlikely case, isn't it?
    59                 raise VADE(
    59                 raise VADE(
    60                     _(u'There is no primary domain for the alias domain “%s”.')\
    60                     _(u'There is no primary domain for the alias domain “%s”.')\
    61                             % self.__name, ERR.NO_SUCH_DOMAIN)
    61                             % self.__name, ERR.NO_SUCH_DOMAIN)
    62         else:
    62         else:
    63             raise VADE(_(u"The alias domain “%s” doesn't exist yet.") %
    63             raise VADE(_(u"The alias domain “%s” doesn't exist.") %
    64                     self.__name, ERR.NO_SUCH_ALIASDOMAIN)
    64                     self.__name, ERR.NO_SUCH_ALIASDOMAIN)
    65 
    65 
    66     def switch(self):
    66     def switch(self):
    67         if self._domain is None:
    67         if self._domain is None:
    68             raise VADE(_(u'No destination domain for alias domain denoted.'),
    68             raise VADE(_(u'No destination domain specified for alias domain.'),
    69                     ERR.ALIASDOMAIN_NO_DOMDEST)
    69                     ERR.ALIASDOMAIN_NO_DOMDEST)
    70         if self._domain._id < 1:
    70         if self._domain._id < 1:
    71             raise VADE (_(u"The target domain “%s” doesn't exist yet.") %
    71             raise VADE (_(u"The target domain “%s” doesn't exist.") %
    72                     self._domain._name, ERR.NO_SUCH_DOMAIN)
    72                     self._domain._name, ERR.NO_SUCH_DOMAIN)
    73         if self.__gid < 1:
    73         if self.__gid < 1:
    74             raise VADE(_(u"The alias domain “%s” doesn't exist yet.") %
    74             raise VADE(_(u"The alias domain “%s” doesn't exist.") %
    75                     self.__name, ERR.NO_SUCH_ALIASDOMAIN)
    75                     self.__name, ERR.NO_SUCH_ALIASDOMAIN)
    76         if self.__gid == self._domain._id:
    76         if self.__gid == self._domain._id:
    77             raise VADE(_(u"The alias domain “%(alias)s” is already assigned to\
    77             raise VADE(_(u"The alias domain “%(alias)s” is already assigned to\
    78  the domain “%(domain)s”.") %
    78  the domain “%(domain)s”.") %
    79                     {'alias': self.__name, 'domain': self._domain._name},
    79                     {'alias': self.__name, 'domain': self._domain._name},
    92  AND NOT is_primary', self.__name)
    92  AND NOT is_primary', self.__name)
    93             if dbc.rowcount > 0:
    93             if dbc.rowcount > 0:
    94                 self._dbh.commit()
    94                 self._dbh.commit()
    95         else:
    95         else:
    96             raise VADE(
    96             raise VADE(
    97                   _(u"The alias domain “%s” doesn't exist yet.") % self.__name,
    97                   _(u"The alias domain “%s” doesn't exist.") % self.__name,
    98                   ERR.NO_SUCH_ALIASDOMAIN)
    98                   ERR.NO_SUCH_ALIASDOMAIN)
    99 
    99