Exemple #1
0
def addAsset():
	sn = request.form.get('sn', '')
	vendor = request.form.get('vendor', '')
	machine_room = request.form.get('machine_room', '')
	model = request.form.get('model', '')
	purchase_date = request.form.get('purchase_date', '')
	cpu = request.form.get('cpu', '')
	ram = request.form.get('ram', '')
	disk = request.form.get('disk', '')
	os = request.form.get('os', '')
	ip = request.form.get('ip', '')
	hostname = request.form.get('hostname', '')
	admin = request.form.get('admin', '')
	business = request.form.get('business', '')
	# 检查用户提交的数据
	ok, result = models.validate_asset_add(sn, vendor, machine_room, model, purchase_date, cpu, ram, disk, os, ip, hostname, admin, business)

	if ok:
		if models.add_asset(sn, vendor, machine_room, model, purchase_date, cpu, ram, disk, os, ip, hostname, admin, business):
			ok = True
			result = u'添加成功'
		else:
			ok = False
			result = u'添加失败'

	if ok:
		return render_template('asset.html')
	else:
		return render_template('asset.html', result=result, sn=sn, vendor=vendor, machine_room=machine_room, 
			model=model, purchase_date=purchase_date, cpu=cpu, ram=ram, disk=disk, os=os, ip=ip, hostname=hostname, 
			admin=admin, busines=business)

			
	return json.dumps({'ok': ok, 'result': result})
Exemple #2
0
def addAsset():
    _asset = models.create_asset_obj(request.form)
    
    # 检查用户提交的数据
    ok, result, errors = models.validate_asset_add(_asset)

    if ok:
        if models.add_asset(_asset):
            ok = True
            result = '添加成功'
        else:
            ok = False
            result = '添加失败'

    return json.dumps({'ok' : ok, 'result' : result, 'errors' : errors})