Ejemplo n.º 1
0
Archivo: views.py Proyecto: asmcos/jeap
def edit_c(c_name,id):
    if require_login():
          return redirect(url_for(login))
    c = mcourses.get(mcourses.c.id == id)
    if cmp(c.adminname,request.user.username) and (request.user.is_superuser == False):
        return redirect('/message/您不是该课程的管理者/-1')
    if request.method == 'GET': 
		c = mcourses.get(mcourses.c.id == id)
		form = CoursesForm(data ={'c_name':c.c_name,'c_desc':c.c_desc})
		return {'form':form}	
    elif request.method == 'POST':
            form = CoursesForm()
            flag = form.validate(request.params)
            if flag:
                n=mcourses.get(int(id))
                n.c_desc = form.data.c_desc
                n.save()
                ne = events()
                ne.username = request.user.username
                ne.action = '修改了课程'
                ne.objs = form.data.c_name
                ne.save()
                return redirect('/message/添加完成/-2')
            else:
                message='错误'
                return {'form':form}
Ejemplo n.º 2
0
Archivo: views.py Proyecto: asmcos/jeap
def add_b(reg_name,reg_id):
        if require_login():
            return redirect(url_for(login))
        form = BitsForm()
        if request.method == 'GET':
            b=mbits.filter(mbits.c.reg_id==reg_id) 
            return {'form':form,'reg_name':reg_name,'b':b}
        elif request.method == 'POST':
            flag = form.validate(request.params)
            if flag:
                n = mbits(**form.data)
                b = mbits.filter(mbits.c.bits_name == form.data.bits_name)\
                         .filter(mbits.c.reg_id == reg_id)
                for b1 in b:
                    return redirect('/message/添加错误,重名/-1') 
                n.reg_name = reg_name
                n.reg_id = reg_id
                n.save()
                ne = events()
                ne.username = request.user.username
                ne.action = '增加了位说明'
                ne.objs = reg_name
                ne.save()
                return redirect('/regs/add_b/%s/%s'% (reg_name,reg_id))
            else:
                message='错误'
                return {'form':form}
Ejemplo n.º 3
0
Archivo: views.py Proyecto: asmcos/jeap
def add_r(device_name,device_id):
        if require_login():
            return redirect(url_for(login))
        form = RegForm()
        if request.method == 'GET':
            return {'form':form}
        elif request.method == 'POST':
            flag = form.validate(request.params)
            if flag:
                n = mreg(**form.data)
                r = mreg.filter(mreg.c.reg_name == form.data.reg_name).filter(mreg.c.device_id==device_id)
                for r1 in r:
                    return redirect('/message/添加错误,重名/-1') 
                n.adminname = request.user
                n.device_name = device_name
                n.device_id   = device_id
                n.save()
                ne = events()
                ne.username = request.user
                ne.action = '增加了寄存器'
                ne.objs = form.data.reg_name
                ne.save()
                return redirect('/message/添加完成/-2') 
            else:
                message='错误'
                return {'form':form}
Ejemplo n.º 4
0
Archivo: views.py Proyecto: asmcos/jeap
def delete_c(id):
    if require_login():
        return redirect(url_for(login))
    c=mcourses.get(int(id))
    if cmp(c.adminname,request.user.username) and (request.user.is_superuser == False):
        return redirect('/message/您不是该课程的管理者/-1')
    c.delete()
    ne = events()
    ne.username = request.user
    ne.action = '删除了课程'
    ne.objs = c.c_name
    ne.save()
    return redirect('/message/删除完成/-2')
Ejemplo n.º 5
0
Archivo: views.py Proyecto: asmcos/jeap
def add_cp(c_name):
    	if require_login():
        	return redirect(url_for(login))
        form = CDPForm()
        if request.method == 'GET':
            return {'form':form,'c_name':c_name}
        elif request.method == 'POST':
            flag = form.validate(request.params)
            if flag:
                n = cdp(**form.data)
                n.c_name = c_name
                n.save()
                ne = events()
                ne.username = request.user.username
                ne.action = '增加了知识点依赖'
                ne.objs = c_name
                ne.save()
                return redirect('/message/添加完成/-2')
            else:
                message='错误'
                return {'form':form}
Ejemplo n.º 6
0
Archivo: views.py Proyecto: asmcos/jeap
def add_c():
        if require_login():
             return redirect(url_for(login))
        form = CoursesForm()
        if request.method == 'GET':
            return {'form':form}
        elif request.method == 'POST':
            flag = form.validate(request.params)
            if flag:
                n = mcourses(**form.data)
                c = mcourses.get(mcourses.c.c_name == form.data.c_name)
                if c:
                   return redirect('/message/添加错误,重名/-2')
                n.adminname=request.user
                n.save()
                ne = events()
                ne.username = request.user
                ne.action = '增加了课程'
                ne.objs = form.data.c_name
                ne.save()
                return redirect('/message/添加完成/-2')
            else:
                message='错误'
                return {'form':form}