Commits

Zhang Huangbin committed 9afe592

Code cleanup.

Comments (0)

Files changed (3)

controllers/dbmail_mysql/alias.py

     @decorators.require_login
     def GET(self, domain, cur_page=1):
         self.domain = web.safestr(domain)
-        cur_page = int(cur_page)
-
-        if not iredutils.isDomain(self.domain):
-            raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
-
-        if cur_page == 0:
-            cur_page = 1
+        cur_page = int(cur_page) or 1
 
         aliasLib = aliaslib.Alias()
         result = aliasLib.listAccounts(domain=self.domain, cur_page=cur_page,)
     @decorators.require_login
     def POST(self, domain):
         i = web.input(_unicode=False, mail=[])
-
-        self.domain = str(domain)
-        if not iredutils.isDomain(self.domain):
-            raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
+        self.domain = web.safestr(domain)
 
         self.mails = i.get('mail', [])
         self.action = i.get('action', None)

controllers/dbmail_mysql/domain.py

         self.domain = web.safestr(domain.split('/', 1)[0])
         self.profile_type = web.safestr(profile_type)
 
-        if not iredutils.isDomain(self.domain):
-            raise web.seeother('/domains?msg=EMPTY_DOMAIN')
-
         domainLib = domainlib.Domain()
         result = domainLib.profile(domain=self.domain)
 
         # Get sender/recipient throttle data from policyd database.
         if session.get('enablePolicyd'):
             throttleLib = throttle.Throttle()
-            result_throttle = throttleLib.list(sender='@' + self.domain, recipient='@' + self.domain)
+            result_throttle = throttleLib.getThrottling(sender='@' + self.domain, recipient='@' + self.domain)
             if result_throttle[0] is True:
                 throttleOfSender = result_throttle[1]
                 throttleOfRecipient = result_throttle[2]

controllers/dbmail_mysql/user.py

     @decorators.require_login
     def GET(self, domain, cur_page=1):
         self.domain = web.safestr(domain).split('/', 1)[0]
-        cur_page = int(cur_page)
-
-        if not iredutils.isDomain(self.domain):
-            raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
-
-        if cur_page == 0:
-            cur_page = 1
+        cur_page = int(cur_page) or 1
 
         userLib = userlib.User()
         result = userLib.listAccounts(domain=self.domain, cur_page=cur_page,)
     @decorators.require_login
     def POST(self, domain):
         i = web.input(_unicode=False, mail=[])
-
-        self.domain = str(domain)
-
-        if not iredutils.isDomain(self.domain):
-            raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME')
+        self.domain = web.safestr(domain)
 
         self.mails = [str(v)
                       for v in i.get('mail', [])