コード例 #1
0
def userlist():
    if not session.get('name',None):
	return redirect('/login')
    fields = ['id','name','name_cn','mobile','email','role','status']
    table = 'users'
    result = user_db.selectAll(fields,table)
    data = [dict((k,row[i]) for i,k in enumerate(fields)) for row in result]
    return render_template('userlist.html',users=data,info=session)
コード例 #2
0
def idc():
    if not session.get('name',None):
	return redirect('/login')
    fields = ['id','name','isp','contact','mobile','address']
    table = 'idc'
    result = user_db.selectAll(fields,table)
    data = [dict((k,row[i]) for i,k in enumerate(fields)) for row in result]
    return render_template('idc.html',idcs=data,info=session)
コード例 #3
0
def userlist():
    if not session.get('name',None):
	return redirect('/login')
    users = []
    fields = ['id', 'name', 'name_cn', 'email', 'mobile']
    try:
        role = session['role']
        if role != 'admin':
	    condition = 'name = "%s"' % session.get('name',None)
	    result = user_db.selectOne(fields,condition)
	    users = [dict((k,result[i]) for i,k in enumerate(fields))]
	else:
	    result = user_db.selectAll(fields)
            users = [dict((k,row[i]) for i,k in enumerate(fields)) for row in result]
        return  render_template('userlist.html', users = users)
    except:
        errmsg = "select userlist failed"
        print traceback.print_exc()
        return  render_template("userlist.html",result=errmsg)
コード例 #4
0
def userlist():
    if not session.get('name', None):
        return redirect('/login')
    users = []
    fields = ['id', 'name', 'name_cn', 'email', 'mobile']
    try:
        role = session['role']
        if role != 'admin':
            condition = 'name = "%s"' % session.get('name', None)
            result = user_db.selectOne(fields, condition)
            users = [dict((k, result[i]) for i, k in enumerate(fields))]
        else:
            result = user_db.selectAll(fields)
            users = [
                dict((k, row[i]) for i, k in enumerate(fields))
                for row in result
            ]
        return render_template('userlist.html', users=users)
    except:
        errmsg = "select userlist failed"
        print traceback.print_exc()
        return render_template("userlist.html", result=errmsg)