Example #1
0
def getUsers():
    l=conecta()
    g = Groups(l,"",request.vars['row_id'],"")
    response = g.listUsers(request.vars)
    l.close()

    # Obtenemos los numeros de serie de los portatiles
    sql = "SELECT lh.username, l.serial_number, lt.trademark, lt.model FROM laptops l" 
    sql = sql+" LEFT JOIN laptops_historical lh ON l.id_laptop=lh.id_laptop"
    sql = sql+" LEFT JOIN laptops_trademarks lt ON l.id_trademark=lt.id_trademark" 
    sql = sql+" GROUP BY l.id_laptop ORDER BY lh.datetime desc"
    result = cdb.executesql(sql)

    serials={}
    for r in result:
        if str(r[0])!="":
            serials[str(r[0])]={'serial':str(r[1]), 'trademark':str(r[2])+' - '+str(r[3])}

    rows=[]
    for r in response["rows"]:
        num=""
        trademark=""
        if r["cell"][1] in serials:
            num = serials[r["cell"][1]]['serial']
            trademark = serials[r["cell"][1]]['trademark']

        r["cell"].append(num)
        r["serial_number"]=num
        r["cell"].append(trademark)
        r["trademark"]=trademark
        rows.append(r)

    response["rows"]=rows
    return response  
Example #2
0
def getDataStudents(classroom):
    from applications.controlies.modules.Groups import Groups

    l = conecta()
    g = Groups(l, "", classroom, "")
    listUsers = g.listUsers({
        'rows': '40',
        'page': '1',
        'sidx': 'cn',
        'sord': 'desc'
    })
    l.close()

    # Obtenemos los numeros de serie de los portatiles
    sql = "SELECT lh.username, l.serial_number, lt.trademark, lt.model, st.state FROM laptops l, laptops_historical lh"
    sql = sql + " LEFT JOIN laptops_trademarks lt ON l.id_trademark=lt.id_trademark"
    sql = sql + " LEFT JOIN states st ON st.id_state=lh.id_state "
    sql = sql + " WHERE lh.id_user_type=2 AND l.id_laptop=lh.id_laptop "
    sql = sql + " AND lh.id_historical IN (SELECT MAX(lh2.id_historical) FROM laptops_historical lh2 WHERE lh2.id_laptop=l.id_laptop) "
    sql = sql + " GROUP BY l.id_laptop ORDER BY lh.name asc"
    result = cdb.executesql(sql)
    serials = {}
    for r in result:
        if str(r[0]) != "":
            serials[str(r[0])] = {
                'serial': str(r[1]),
                'trademark': str(r[2]) + ' - ' + str(r[3]),
                'state': str(r[4].encode('utf-8'))
            }

    rows = []
    for r in listUsers["rows"]:
        num = ""
        trademark = ""
        state = " "
        if r["cell"][1] in serials:
            num = serials[r["cell"][1]]['serial']
            trademark = serials[r["cell"][1]]['trademark']
            state = serials[r["cell"][1]]['state']

        if num == "":
            num = "                                              "

        if trademark == "":
            trademark = "                                         "

        r["cell"].append(num)
        r["serial_number"] = num
        r["cell"].append(trademark)
        r["trademark"] = trademark
        r["state"] = state
        rows.append(r)

    return rows
Example #3
0
def getDataStudents(classroom):
    from applications.controlies.modules.Groups import Groups

    l=conecta()
    g = Groups(l,"",classroom,"")
    listUsers = g.listUsers({'rows':'40', 'page':'1', 'sidx':'cn', 'sord':'desc'})
    l.close()

    # Obtenemos los numeros de serie de los portatiles
    sql = "SELECT lh.username, l.serial_number, lt.trademark, lt.model FROM laptops l" 
    sql = sql+" LEFT JOIN laptops_historical lh ON l.id_laptop=lh.id_laptop"
    sql = sql+" LEFT JOIN laptops_trademarks lt ON l.id_trademark=lt.id_trademark" 
    sql = sql+" GROUP BY l.id_laptop ORDER BY lh.datetime desc"
    result = cdb.executesql(sql)

    serials={}
    for r in result:
        if str(r[0])!="":
            serials[str(r[0])]={'serial':str(r[1]), 'trademark':str(r[2])+' - '+str(r[3])}

    rows=[]
    for r in listUsers["rows"]:
        num=""
        trademark=""
        if r["cell"][1] in serials:
            num = serials[r["cell"][1]]['serial']
            trademark = serials[r["cell"][1]]['trademark']

        if num=="":
            num = "                                              "

        if trademark=="":
            trademark = "                                         "

        r["cell"].append(num)
        r["serial_number"]=num
        r["cell"].append(trademark)
        r["trademark"]=trademark
        rows.append(r)
        
    return rows
Example #4
0
def getUsers():
    l = conecta()
    g = Groups(l, "", request.vars["row_id"], "")
    response = g.listUsers(request.vars)
    l.close()
    return response
Example #5
0
def getUsers():
    l = conecta()
    g = Groups(l, "", request.vars['row_id'], "")
    response = g.listUsers(request.vars)
    l.close()
    return response