예제 #1
0
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)
예제 #2
0
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='添加失败,您可能没有填写项目名称,请仔细检查')
예제 #3
0
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)
예제 #4
0
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='删除失败!')
예제 #5
0
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='修改失败!')
예제 #6
0
def index():
    user = None
    userid = request.cookies.get('uid')
    user = ormmanage.queryUname(userid)
    return render_template('index.html', userinfo=user)