def updSchool(): pass ret = checkAuth() if ret != None: return ret sch_id = request.args.get('sch_id') if sch_id == None: return bad_request(None, 'sch_id is None') mysqlSession = mysql.session school = mysqlSession.query(School).filter(School.sch_id == sch_id).first() form = SchoolForm() if form.validate_on_submit(): pass school.full_name = request.form['full_name'] school.en_name = request.form['en_name'] school.nick_list = request.form['nick_list'] school.tel = request.form['tel'] school.email = request.form['email'] school.push_url = request.form['push_url'] try: mysqlSession.add(school) mysqlSession.commit() return execSuccess('修改成功') except sqlalchemy.exc.IntegrityError, e: mysqlSession.rollback() return bad_request(e) except Exception, e: mysqlSession.rollback() return bad_request(e)
def addSchool(): pass ret = checkAuth() if ret != None: return ret form = SchoolForm() if form.validate_on_submit(): school = School() school.full_name = request.form['full_name'] school.en_name = request.form['en_name'] school.nick_list = request.form['nick_list'] school.tel = request.form['tel'] school.email = request.form['email'] school.push_url = request.form['push_url'] mysqlSession = mysql.session try: mysqlSession.add(school) mysqlSession.commit() except sqlalchemy.exc.IntegrityError, e: mysqlSession.rollback() return bad_request(e) except Exception, e: mysqlSession.rollback() return bad_request(e)