def find(self,s):
        pp_diy = r"^借书\Z"

        if re.search(pp_diy, str(s.content)):
            from app.model.dll_library import getLib
            from app.model.db_user import User
            temUser = User(s.userName)
            id = temUser.query("ss_num")
            password = temUser.query("password_inf")
            if temUser.query("bind") == 0:
                return '您还未绑定,请先<a href="' + URL + 'bind'+str(s.userName)+'">绑定</a>'
            else:
                book_info, status = getLib(id, password)
                cnt = 1
                if status == '-3':
                    res = '绑定的信息有误,请重新<a href="' + URL + 'bind'+str(s.userName)+'">绑定</a>'
                    return res
                elif not book_info:
                    res = "你还没有借书哦~~~"
                    return res
                else:
                    res = "以下是你借的书及到期时间: \n"
                    for i in book_info:
                        res = res + str(cnt) + ". 《" + i['book']+ "》\n" + "到期时间:" + i['duetime'] +'\n'
                        cnt += 1
                return res + "回复'xj+序号'(如xj1)即可续借相应书籍~~"
        else:
            return 0
    def find(self,s):
        pp_diy = ur"^xj"

        if re.search(pp_diy, str(s.content)):
            from app.model.dll_library import getLib
            from app.model.db_user import User
            temUser = User(s.userName)
            id = temUser.query("ss_num")
            password = temUser.query("password_inf")
            if temUser.query("bind") == 0:
                return '您还未绑定,请先<a href="' + URL + 'bind' +str(s.userName)+'">绑定</a>'
            append = s.content[2:]
            if append:
                status = getLib(id, password, append)[1]
                if status == '1':
                    res = "续借成功,回复[借书]查看详情"
                elif status == '-1':
                    res = '这本书已达到续借限制,无法续借'
                elif status == '-2':
                    res = '这本书不能续借哦~~'
                elif status == '0':
                    res = '请输入正确的序号(如xj1)'
                elif status == '-3':
                    res = '绑定的信息有误,请重新<a href="http://4.wx4321.sinaapp.com/bind'+str(s.userName)+'">绑定</a>'
                else:
                    pass
            else:
                res = '请输入正确的序号(如xj1)'
            return res
        else:
            return 0
Exemple #3
0
def handle(ori_message):
    rec = ElementTree.fromstring(ori_message)

    fromUserName= findNode(rec, "FromUserName")
    toUserName = findNode(rec, "ToUserName")
    content = findNode(rec, "Content")
    createTime = findNode(rec, "CreateTime")
    msgType =findNode(rec, "MsgType")
    msgId = findNode(rec, "MsgId")
    picUrl = findNode(rec, "PicUrl")        #图片
    mediaUrl = findNode(rec, "MediaUrl")    #图片
    format = findNode(rec, "Format")        #语音
    recognition = findNode(rec, "Recognition")  #语音
    event = findNode(rec ,"Event")
    eventKey = findNode(rec, "EventKey") #click点击的key
    # userInfo = userDB(fromUserName)
    userInfo = User(wxid=fromUserName)
    userInfo.save()
    if msgType == "text":
        msg = app.model.message.Message_Text(content=content, userInfo=userInfo,
                                   msgId=msgId, createTime=createTime)
    elif msgType == "event" and event == "CLICK":
        msg = app.model.message.Message_Text(content=str(eventKey), userInfo=userInfo,
                                   msgId=msgId, createTime=createTime)
    elif msgType == "event" and event == "subscribe":
        msg = app.model.message.Message_Text(content="_sub", userInfo=userInfo,
                           msgId=msgId, createTime=createTime)
    else:
        msg = app.model.message.Message_Text(content="_*-.", userInfo=userInfo,
                           msgId=msgId, createTime=createTime)
    return msg.result().format(toUserName)
Exemple #4
0
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)
Exemple #5
0
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)
    def find(self,s):
        pp_diy = "成绩"

        if re.search(pp_diy, str(s.content)):
            from app.model.db_user import User
            temUser = User(s.userName)
            res=""
            if not temUser.isbind():
                return '您还未绑定,请先<a href="' + URL + 'bind'+str(s.userName)+'">绑定</a>'
            else:
                grade_list = ""
                try:
                    grade_list = list(eval(temUser.query("grade").decode("utf8")))
                except Exception:
                    pass
            add = '<a href="' + URL + 'grade'+str(s.userName)+'">点此更新成绩</a>'
            if grade_list == "":
                pass
            else:
                for i in grade_list:
                    res = res + "\n" + str(i['name']) + " " + str(i['grade'])
            return res + "\n" + add
        else:
            return 0