Beispiel #1
0
def delete_r(id):
    if require_login():
        return redirect(url_for(login))
    r = mreg.get(mreg.c.id == id)
    if cmp(r.adminname,request.user.username) and (request.user.is_superuser == False):
        return redirect('/message/您不是该知识点的管理者/-1')
    r.delete()
    return redirect('/message/删除完成/-2')
Beispiel #2
0
def display_r(id):
    ms = []
    r = mreg.get(mreg.c.id == id)
    b = mbits.filter(mbits.c.reg_id == id)
    for b1 in b:
        m = mmeanings.filter(mmeanings.c.bits_id==b1.id)
        for m1 in m:
            ms.append(m1)
    return {'r':r,'b':b,'ms':ms}
Beispiel #3
0
def delete_mean(id):
    if require_login():
         return redirect(url_for(login))
    m = mmeanings.get(mmeanings.c.id == id)
    b = mbits.get(mbits.c.id == m.bits_id)
    r = mreg.get(mreg.c.id == b.reg_id)
    if cmp(r.adminname,request.user.username) and (request.user.is_superuser == False):
        return redirect('/message/您不是该知识点的管理者/-1')
    m.delete()
    return redirect('/message/删除完成/-2')
Beispiel #4
0
def edit_r(id):
    if require_login():
         return redirect(url_for(login))
    r = mreg.get(mreg.c.id == id)
    if cmp(r.adminname,request.user.username) and (request.user.is_superuser == False):
        return redirect('/message/您不是该知识点的管理者/-1')
    if request.method == 'GET': 
		r = mreg.get(mreg.c.id == id)
		form = RegForm(data ={'reg_name':r.reg_name,'reg_desc':r.reg_desc,\
							'reg_address':r.reg_address})
		return {'form':form}	
    elif request.method == 'POST':
            form = RegForm()
            flag = form.validate(request.params)
            if flag:
                n=mreg.get(int(id))
                n.reg_name= form.data.reg_name
                n.reg_desc= form.data.reg_desc
                n.reg_address= form.data.reg_address
                n.save()
                return redirect('/message/编辑完成/-2')
            else:
                message='错误'
                return {'form':form}
Beispiel #5
0
def search(id):
    if request.method == 'GET':
        return redirect("/regs/display_r/%s"% id)
    m = []
    ms = []
    b1 = []
    r = mreg.get(mreg.c.id == id)
    b = mbits.filter(mbits.c.reg_id == id)
    if request.method == 'POST':
        rvalue = request.params.get('rvalue')
    for n in b:
        n.val = regcal(int(n.bits_sbit),int(n.bits_ebit),int(rvalue,16)) 
        b1.append(n)
        mean = mmeanings.filter(mmeanings.c.bits_id==n.id).filter(mmeanings.c.val==str(n.val))
        for me1 in mean:
            m.append(me1)
    for b2 in b:
        m2 = mmeanings.filter(mmeanings.c.bits_id==b2.id)
        for m1 in m2:
            ms.append(m1)
    return {'r':r,'b1':b1,'m':m,'rvalue':rvalue,'ms':ms}