def post(self): porject = self.get_argument('porject') banbenhao = self.get_argument('banbenhao') new = BanbenWrite.get_by_name(banbenhao) if new: self.render('addbanben.html', error_message='版本号不能重复', porjects=self.porjects) shangxian = self.get_argument('shangxian') test = self.get_argument('test') login_user = self.get_current_user() if not banbenhao: self.render('addbanben.html', error_message='版本号不能为空', porjects=self.porjects) new_ban = BanbenWrite(porject_id=int(porject), banbenhao=banbenhao, is_xian=shangxian, is_test=test, user_id=login_user.id) db_session.add(new_ban) try: db_session.commit() self.redirect('/banben') except Exception as e: db_session.rollback() self.render('addbanben.html', error_message='添加失败', porjects=self.porjects)
def get(self,id): banben=BanbenWrite.get_by_id(id) if banben and banben.status==1: banben.status=0 db_session.commit() self.redirect('/banben') self.redirect('/banben')
def get(self, page=1): count = BanbenWrite.get_count() obj = Pagination(page, count) testresults = db_session.query(BanbenWrite).order_by( BanbenWrite.creat_time.desc())[int(obj.start):(int(page)) * (12)] str_page = obj.string_pager('/banben/') self.render('banben.html', banbnens=testresults, str_page=str_page)
def post(self,id): banben=BanbenWrite.get_by_id(id) porject=self.get_argument('porject') banbenhao=self.get_argument('banbenhao') shangxian=self.get_argument('shangxian') test=self.get_argument('test') if not banbenhao: self.render('editbanben.html',banben=banben,porjects=self.porjects,error_message='请准确填写版本信息') banben.banbenhao=banbenhao banben.is_xian=shangxian banben.is_test=test banben.porject_id=int(porject) try: db_session.commit() self.redirect('/banben') except Exception as e: #raise e self.render('editbanben.html',banben=banben,porjects=self.porjects,error_message='编辑失败')
def get(self,id): banben=BanbenWrite.get_by_id(id) self.render('editbanben.html',banben=banben,porjects=self.porjects,error_message=None)