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_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 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 dir_scan(): target = str(request.args.get('target', '')) if target.startswith('http://') or target.startswith('https://'): pass else: target = 'http://' + target if target.endswith('/'): target = target[:-1] types = str(request.args.get('type', '')).split(',') dirscan = DirScan(target, types=types) dirscan.run() return success(dirscan.get_data())
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 x_get(): cul_products = [cul_product.to_json() for cul_product in CulProduct.query.filter(CulProduct.verify_res==2,CulProduct.progress == 1).all()] return success(cul_products)
def y_get(user): products = [product.to_json() for product in CulProduct.query.filter(CulProduct.progress == 0,CulProduct.academy == user.academy).all()] return success(products)
def x_get(): goods = [ good.to_json() for good in Good.query.filter( Good.progress == 1, Good.verify_res == 2).all() ] return success(goods)
def y_get(user): goods = [ good.to_json() for good in Good.query.filter( Good.progress == 0, Good.academy == user.academy).all() ] return success(goods)