def grade(id): JSESSIONID = "" if request.method == "GET": temUser = User(wxid=id) if temUser.query("wxid") == -1: return render_template("result.html", words="您还没有绑定帐号,请绑定后重试") resp = make_response(render_template("easy_grade.html")) return resp else: imgcode = request.form["imgcode"] JSESSIONID = request.cookies.get("JSESSIONID") temUser = User(wxid=id) id = temUser.query("ss_num") pwd = temUser.query("password_edu") grade = gradeResult(id, pwd, imgcode, JSESSIONID) if grade == -1: return render_template("easy_grade.html", info="验证码错误") if grade == -2: return render_template("easy_grade.html", info="学号或密码错误") if grade == -3: return render_template("grade.html", info="会话超时") grade = MySQLdb.escape_string(str(grade)) # 转换为正常格式 temUser.update(grade=grade) return render_template("result.html", words="成绩更新成功", back=1)
def bind(id): if request.method == "GET": return render_template("bind.html") else: ss_num = request.form["ss_num"] password_edu = request.form["password_edu"] password_lib = request.form["password_lib"] password_inf = request.form["password_inf"] name = request.form["name"] temUser = User(wxid=id) kwags = {} for i in request.form: if request.form[i]: kwags[i] = request.form[i] if temUser.update(**kwags): temUser.tobind() return render_template("result.html", words = "绑定成功", back = 1)