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)
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)
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)
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)
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
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
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)
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)
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
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)
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)