def list(): if request.method == 'GET': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) ps = ormmanage.obtainProject(userid) return render_template('list.html', ps=ps, userinfo=uname) elif request.method == 'POST': search = request.form['search'] userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) ps = ormmanage.search(search, userid) if ps == 'fail': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) ps = ormmanage.obtainProject(userid) return render_template('list.html', ps=ps, userinfo=uname, content=search) elif ps == 'kong': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) ps = ormmanage.obtainProject(userid) return render_template('list.html', ps=ps, userinfo=uname, tips='!没有找到你所要查找的文章!请换个搜索试试', content=search) else: return render_template('list.html', sps=ps, userinfo=uname, content=search)
def add(): if request.method == 'GET': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) return render_template('add.html', userinfo=uname) elif request.method == 'POST': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) pnam = request.form['pname'] pdetails = request.form['pdetails'] r = ormmanage.addProject(pnam, pdetails, userid) if r == 'success': return render_template('add.html', userinfo=uname, tips='添加成功!') else: return render_template('add.html', userinfo=uname, tips='添加失败,您可能没有填写项目名称,请仔细检查')
def detail(pid): userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) p = ormmanage.qureyPdetails(pid) return render_template('detail.html', userinfo=uname, nr=p.pdetails, pname=p.pname, p=p)
def delete(pid): r = ormmanage.delete(pid) if r == 'success': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) ps = ormmanage.obtainProject(userid) return render_template('list.html', ps=ps, userinfo=uname, tips='删除成功!') else: userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) ps = ormmanage.obtainProject(userid) return render_template('list.html', ps=ps, userinfo=uname, tips='删除失败!')
def modify(pid): if request.method == 'GET': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) p = ormmanage.qureyPdetails(pid) return render_template('modify.html', userinfo=uname, p=p) elif request.method == 'POST': pname = request.form['pname'] if not pname: userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) p = ormmanage.qureyPdetails(pid) return render_template('modify.html', userinfo=uname, p=p, tips='项目名不能为空!') else: pdetails = request.form['pdetails'] r = ormmanage.modify(pid, pname, pdetails) if r == 'success': userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) p = ormmanage.qureyPdetails(pid) return render_template('modify.html', userinfo=uname, p=p, tips='修改成功!') else: userid = request.cookies.get('uid') uname = ormmanage.queryUname(userid) p = ormmanage.qureyPdetails(pid) return render_template('modify.html', userinfo=uname, p=p, tips='修改失败!')
def index(): user = None userid = request.cookies.get('uid') user = ormmanage.queryUname(userid) return render_template('index.html', userinfo=user)