def post(self, id):
     weblog.info("%s.", self._request_summary())
     Projectname = self.get_argument("Projectname", None)
     passowrd = self.get_argument("passowrd", None)
     Projectemail = self.get_argument("Projectemail", None)
     Projectrole = self.get_argument("Projectrole")
     msg = []
     if Projectname is None or Projectname == "":
         msg.append(msg_define.ProjectNAME_IS_EMPTY)
     if passowrd is None or check_passord(passowrd) is None:
         msg.append(msg_define.ProjectPASSWORD_INVALID)
     if Projectemail is None or Projectemail == "":
         msg.append(msg_define.ProjectEMAIL_IS_EMPTY)
     elif check_email(Projectemail) is None:
         msg.append(msg_define.ProjectEMAIL_INVALID)
     if msg:
         return self.render('admin/Projectedit.html', message=msg)
     else:
         try:
             old_Project = get_project_by_id(self, id)
             old_Project.Projectname = Projectname
             old_Project.password = passowrd
             old_Project.email = Projectemail
             old_Project.Projectrole = Projectrole
             self.mysqldb().commit()
             return self.redirect('/Project/list')
         except:
             weblog.exception("Edit Project error!")
             self.mysqldb().rollback()
             return self.render('admin/Projectedit.html', message=msg)
Beispiel #2
0
 def post(self, id):
     weblog.info("%s.", self._request_summary())
     username = self.get_argument("username", None)
     passowrd = self.get_argument("passowrd", None)
     useremail = self.get_argument("useremail", None)
     userrole = self.get_argument("userrole")
     msg = []
     if username is None or username == "":
         msg.append(msg_define.USERNAME_IS_EMPTY)
     if passowrd is None or check_passord(passowrd) is None:
         msg.append(msg_define.USERPASSWORD_INVALID)
     if useremail is None or useremail == "":
         msg.append(msg_define.USEREMAIL_IS_EMPTY)
     elif check_email(useremail) is None:
         msg.append(msg_define.USEREMAIL_INVALID)
     if msg:
         return self.render('admin/useredit.html', message=msg)
     else:
         try:
             old_user = get_user_by_id(self, id)
             old_user.username = username
             old_user.password = passowrd
             old_user.email = useremail
             old_user.userrole = userrole
             self.mysqldb().commit()
             return self.redirect('/user/list')
         except:
             weblog.exception("Edit user error!")
             self.mysqldb().rollback()
             return self.render('admin/useredit.html', message=msg)
 def post(self):
     weblog.info("%s.", self._request_summary())
     username = self.get_argument("username", None)
     passowrd = self.get_argument("passowrd", None)
     useremail = self.get_argument("useremail", None)
     userrole = self.get_argument("userrole")
     msg = []
     if username is None or username == "":
         msg.append(msg_define.USERNAME_IS_EMPTY)
     if passowrd is None or check_passord(passowrd) is None:
         msg.append(msg_define.USERPASSWORD_INVALID)
     if useremail is None or useremail == "":
         msg.append(msg_define.USEREMAIL_IS_EMPTY)
     elif check_email(useremail) is None:
         msg.append(msg_define.USEREMAIL_INVALID)
     if msg:
         return self.render('admin/useradd.html', message=msg)
     else:
         try:
             new_user = TblAccount()
             new_user.username = username
             new_user.password = passowrd
             new_user.email = useremail
             new_user.userrole = userrole
             new_user.userstate = msg_define.USER_NORMAL
             self.mysqldb().add(new_user)
             self.mysqldb().commit()
             return self.render('admin/usermanage.html',
                                users=get_user_list(self))
         except:
             weblog.exception("Add new user error!")
             self.mysqldb().rollback()
             return self.render('admin/useradd.html', message=msg)