示例#1
0
def todo():
    '''r=requests.get('https://hunter-todo-api.herokuapp.com/todo-item',cookies=cookies)
	text=json.loads(r.text)
	print(text)'''
    global items
    items = getlist(username, cursor, connect)
    return render_template('todo.html', tasks=items)
示例#2
0
def userlist():
    if not session or session["role"] == 1:
        return redirect("/login/")
    result = db.getlist('user', field)
    result = result["msg"]
    print result
    return render_template("userlist.html", result=result)
示例#3
0
def jobhistory():
    if not session.get('username', None):
        return redirect("/login/")
    result = db.getlist("ops_jobs", jobs_field)
    result = result['msg']
    for i in result:
        if i["status"] == 0 and 1:
            result.remove(i)
    return render_template("jobhistory.html", result=result)
示例#4
0
def cabinet():
    if not session or session["role"] == 1:
        return redirect("/login/")
    result = db.getlist('cabinet', cabinet_field)
    result = result["msg"]
    for i in result:
        idc_data = {'id': i['idc_id']}
        idc_result = db.getone('idc', idc_field, idc_data)
        idc_result = idc_result['msg']
        i['idc_id'] = idc_result['name_cn']
    return render_template("cabinet.html", result=result)
示例#5
0
文件: dao.py 项目: dzwarg/vtour
def getresultsbysearch( usr, search ):
	qstring = "SELECT id, thumb_url, page_url, name, user_id, search FROM results WHERE user_id = %d AND search = %d" % (usr, search)
	items = db.getlist( qstring )

	if ( items == None ):
		return None
	else:
		results = []
		for item in items:
			results.append( dataobjects.Result( item ) )

		return results
示例#6
0
文件: dao.py 项目: dzwarg/vtour
def getsearchesintour( usr, tour ):
	qstring = "SELECT id, user_id, tour FROM searches WHERE user_id = %d AND tour = %d" % (usr, tour)
	items = db.getlist( qstring )

	if ( items == None ):
		return None
	else:
		searches = []
		for item in items:
			searches.append( dataobjects.Search( item ) )

		return searches
示例#7
0
def cabinetupdate():
    if not session:
        return redirect("/login/")
    if request.method == "GET":
        idc = db.getlist('idc', idc_field)
        idc = idc["msg"]
        data = {k: v[0] for k, v in dict(request.args).items()}
        result = db.getone('cabinet', cabinet_field, data)
        result = result["msg"]
        return render_template("cabinetupdate.html", result=result, idc=idc)
    elif request.method == "POST":
        data = {k: v[0] for k, v in dict(request.form).items()}
        print data
        result = db.updata('cabinet', data)
        return json.dumps(result)
示例#8
0
def cabinetadd():
    if not session or session["role"] == 1:
        return redirect("/login/")
    result = db.getlist('idc', idc_field)
    idc_id = result["msg"]
    if request.method == "POST":
        cabinet_field = ['id', 'name', 'idc_id', 'u_num', 'power']
        data = {k: v[0] for k, v in dict(request.form).items()}
        result = db.getone('cabinet', cabinet_field, data)
        if result['code'] == 0:
            return json.dumps("机柜名已被使用")
        else:
            cabinet_field = ['name', 'idc_id', 'u_num', 'power']
            result = db.insert('cabinet', cabinet_field, data)
            return json.dumps(result)
    return render_template("cabinetadd.html", idc_id=idc_id)
示例#9
0
文件: dao.py 项目: dzwarg/vtour
def gettoursbyuser(usrorid):
	if (type(usrorid) == type(0)):
		ident = usrorid
	else:
		ident = usrorid.ident

	qstring = "SELECT id, user_id, public, name, date FROM tours WHERE user_id = %d" % ident
	items = db.getlist( qstring )

	if ( items == None ):
		return None
	else:
		tours = []

		for item in items:
			tours.append( dataobjects.Tour( item ) )

		return tours
示例#10
0
def cabinet():
    if not session or session["role"] == 1:
        return redirect("/login/")
    result = db.getlist('cabinet', cabinet_field)
    result = result["msg"]
    return render_template("cabinet.html", result=result)
示例#11
0
def idc():
    if not session or session["role"] == 1:
        return redirect("/login/")
    result = db.getlist('idc', idc_field)
    result = result["msg"]
    return render_template("idc.html", result=result)