Пример #1
0
def edit_p(p_name,id):
	if require_login():
		return redirect(url_for(login))
	p = mpoints.get(mpoints.c.id == id)
	if cmp(p.adminname,request.user.username) and (request.user.is_superuser == False):
		return redirect('/message/您不是该知识点的管理者/-1')
	from forms import PointsForm
	if request.method == 'GET': 
		p = mpoints.get(mpoints.c.id == id)
		form = PointsForm(data ={'p_name':p.p_name,'p_desc':p.p_desc,'p_av_addr':p.p_av_addr})
		return {'form':form}	
	elif request.method == 'POST':
            form = PointsForm()
            flag = form.validate(request.params)
            if flag:
                n=mpoints.get(int(id))
                n.p_name= form.data.p_name
                n.p_desc= form.data.p_desc
                n.p_av_addr= form.data.p_av_addr
                n.save()
                ne = events()
                ne.username = request.user.username
                ne.action = '修改了知识点'
                ne.objs = form.data.p_name
                ne.save()
                return redirect('/message/添加完成/-2')
            else:
                message='错误'
                return {'form':form}
Пример #2
0
def add_p(name):
        if require_login():
			return redirect(url_for(login))
        from forms import PointsForm
        form = PointsForm()
        form.p_name.data = name
        if request.method == 'GET':
            return {'form':form}
        elif request.method == 'POST':
            flag = form.validate(request.params)
            if flag:
                n = mpoints(**form.data)
                p = mpoints.get(mpoints.c.p_name == form.data.p_name)
                if p:
                    return redirect('/message/添加错误,重名/-1')
                n.status = '开启'
                n.adminname = request.user
                n.save()
                ne = events()
                ne.username = request.user
                ne.action = '增加了知识点'
                ne.objs = form.data.p_name
                ne.save()
                return redirect('/message/添加完成/-1') 
            else:
                message='错误'
                return {'form':form}
Пример #3
0
def delete_pco(id):
	if require_login():
		return redirect(url_for(login))
	co = comments.get(comments.c.id == id)
	p = mpoints.get(mpoints.c.p_name == co.comm_objs)
	if cmp(p.adminname,request.user.username) and (request.user.is_superuser == False) :
		return redirect('/message/您不是该主题的管理者/-1')
	co = comments.get(comments.c.id == id)
	co.delete()
	return redirect('/message/删除成功/-2')
Пример #4
0
def delete_p(id):
	if require_login():
		return redirect(url_for(login))
	p = mpoints.get(mpoints.c.id == id)
	if cmp(p.adminname,request.user.username) and (request.user.is_superuser == False):
		return redirect('/message/您不是该知识点的管理者/-1')
	p.delete()
	ne = events()
	ne.username = request.user
	ne.action = '删除了知识点'
	ne.objs = p.p_name
	ne.save()
	return redirect('/message/删除成功/-2')
Пример #5
0
def display_p(p_name,id):
    if request.method == 'POST':
        if require_login():
            return redirect(url_for(login))
        form = CommForm()
        flag = form.validate(request.params)
        if flag:
            co = comments(**form.data)
            co.username = request.user.username
            co.comm_objs = p_name
            co.save()
    pd = mdeps.filter(mdeps.c.d_name==p_name)
    cd = mdeps.filter(mdeps.c.d_parent_name==p_name)
    p = mpoints.get(mpoints.c.p_name == p_name)
    if not p:
        return redirect('/points/add_p/%s' % p_name)
    comm = comments.filter(comments.c.comm_objs==p_name)
    form = CommForm()
    return {'p':p,'pd':pd,'cd':cd,'comm':comm,'form':form}