def goods_check_pass(): userid = session['base_info']['userid'] user = User.query.filter_by(id=userid).first() flag = request.args.get('flag') if not flag: return error('提交参数不合法') s_userid = flag.split('#', 1)[0] s_createtime = flag.split('#', 1)[1] progress = 0 if user.status == 1: progress = 1 elif user.status == 2: progress = 2 else: return error('学生权限不够') good = Good.query.filter(Good.user_id == s_userid, Good.create_time == s_createtime).first() if not good: return error('不存在此申请') if user.status == 1: good.update(verify_res=2, progress=progress, reason='') else: good.update(verify_res=2, progress=progress, reason='', is_lend_return=1) return success({'msg': '审核通过成功', 'good': good.to_json()})
def culture_product_check_pass(): userid = session['base_info']['userid'] user = User.query.filter_by(id=userid).first() flag = request.args.get('flag') if not flag: return error('提交参数不合法') s_userid = flag.split('#', 1)[0] s_createtime = flag.split('#', 1)[1] progress = 0 if user.status == 1: progress = 1 elif user.status == 2: progress = 2 else: return error('学生权限不够') cul_product = CulProduct.query.filter( CulProduct.user_id == s_userid, CulProduct.create_time == s_createtime).first() if not cul_product: return error('不存在此申请') cul_product.update(verify_res=2, progress=progress, reason='') return success({'msg': '审核通过成功', 'cul_product': cul_product.to_json()})
def culture_product_post(): name=request.args.get('name') category=request.args.get('category') num=request.args.get('num') stu_num = request.args.get('stu_num') s_academy = request.args.get('academy') if not (name and category and num and stu_num and s_academy): return error('提交参数不合法') academy = None if get_stu_academy(stu_num) and len(stu_num) == 8: academy = get_stu_academy(stu_num) else: return error('学号不符合规范') if academy != s_academy: return error('学号与学院不符合') userid = session['base_info']['userid'] user = User.query.filter_by(id=userid).first() cul_product=CulProduct(academy,name,category,num,user) cul_product.save() return success('提交成功')
def goods_post(): name = request.args.get('name') category = request.args.get('category') num = request.args.get('num') last_time = request.args.get('last_time') stu_num = request.args.get('stu_num') s_academy = request.args.get('academy') if not (name and category and num and stu_num and s_academy and last_time): return error('提交参数不合法') academy = None if get_stu_academy(stu_num) and len(stu_num) == 8: academy = get_stu_academy(stu_num) else: return error('学号不符合规范') if academy != s_academy: return error('学号与学院不符合') userid = session['base_info']['userid'] user = User.query.filter_by(id=userid).first() good = Good(academy, name, category, num, last_time, user) good.save() return success('提交申请成功')
def goods_confirm_return(): flag = request.args.get('flag') if not flag: return error('提交参数不合法') s_userid = flag.split('#', 1)[0] s_createtime = flag.split('#', 1)[1] userid = session['base_info']['userid'] user = User.query.filter_by(id=userid).first() if user.status != 0: return error('只有学生有权限') good = Good.query.filter(Good.user_id == s_userid, Good.create_time == s_createtime).first() if not good: return error('不存在此申请') good.update(is_lend_return=2) return success('确认归还成功')
def culture_product_get(): userid = session['base_info']['userid'] user = User.query.filter_by(id=userid).first() if user.status==1: return y_get(user) elif user.status==2: return x_get() else: return error('学生没有权限')