Beispiel #1
0
def base_datos():
    import StringIO
    import os

    right_version = right_firefox_version(request.env.http_user_agent)

    if not "archivos" in session.keys():
        session.archivos = []

    form = SQLFORM.factory(submit_button='Enviar')
    if form.accepts(request.vars, session):
        response.flash = 'Procesando datos, espere'
        #borrando = form.vars.principiocurso
        if len(session.archivos) > 0:
            import pdb
            lista_completa = []
            #SQLite=SQLiteConnection()
            #SQLite.define_tables()

            #dbcontrolies = SQLite.getDB()
            #result = db.executesql(sql)
            for archivo in session.archivos:
                f = open(archivo)
                linea = f.readline()
                last_id = ""
                while linea:
                    if linea != '\n' and linea != '':
                        linea = linea.split(",")
                        # Datos del portatil

                        serial_number = linea[1].replace("'", "")
                        id_trademark = linea[2]
                        laptop = Laptops(cdb, "", serial_number, id_trademark)

                        if not laptop.existsSerialNumber(laptop.serial_number):
                            laptop.add()
                            last_id = laptop.getIdbySerialNumber(
                                laptop.serial_number)

                        if last_id:
                            # Datos del registro historico
                            id_laptop = last_id
                            username = linea[9].replace("'", "")
                            name = linea[10].replace("'", "")
                            id_user_type = linea[6]
                            nif = linea[5].replace("'", "")
                            id_state = linea[8]

                            laptopshistory = LaptopsHistory(
                                cdb, "", id_laptop, id_state, id_user_type,
                                nif, username, name, "")
                            laptopshistory.add()
                            #dbcontrolies.laptops_historical.insert (**attributes)

                    linea = f.readline()

            response.flash = T('Ficheros importados correctamente')
            session.archivos = []

    return dict(form=form, right_version=right_version)
Beispiel #2
0
def modifySerialNumber():
    serialNumber = request.vars["serial_number"].strip()
    
    if serialNumber=="":
        response = "unassignment"
    else:
        l = Laptops(cdb,"","","","","","","","")
        id_laptop = l.existsSerialNumber(serialNumber)
        response=""
        if not id_laptop:
            response = "not_exists"
        else:
            lh = LaptopsHistory(cdb,"",id_laptop,"","","","","","")
            data = lh.getLastHistory()
            if data["username"]!="" and data["username"]!=request.vars['id']:
                response = "already_assigned"
            elif data["username"]!="" and data["username"]==request.vars['id']:
                response = "OK"
            else:
                userData = getUserData(request.vars["id"])
    
                lh = LaptopsHistory(cdb,"",id_laptop,"2","2",userData["nif"],request.vars["id"],userData["name"],"Reasignado")
                lh.add()
                response="OK"

    return dict(response=response)
Beispiel #3
0
def base_datos():
    import StringIO
    import os

    right_version=right_firefox_version(request.env.http_user_agent)

    if not "archivos" in session.keys():
        session.archivos=[]    
   
    form=SQLFORM.factory(submit_button='Enviar')
    if form.accepts(request.vars, session):
        response.flash = 'Procesando datos, espere'
        #borrando = form.vars.principiocurso
        if len(session.archivos)>0:
            import pdb
            lista_completa=[]                           
            #SQLite=SQLiteConnection()
            #SQLite.define_tables()
            
            #dbcontrolies = SQLite.getDB()
            #result = db.executesql(sql)
            for archivo in session.archivos:
                f = open(archivo)
                linea = f.readline()
                last_id = ""
                while linea:
                    if linea!= '\n' and linea != '':
                        linea = linea.split(",")
                        # Datos del portatil
                  
                        serial_number = linea[1].replace("'","")
                        id_trademark = linea[2]
                        laptop = Laptops (cdb,"",serial_number, id_trademark)
                                                
                        if not laptop.existsSerialNumber (laptop.serial_number):
                            laptop.add ()
                            last_id = laptop.getIdbySerialNumber (laptop.serial_number)
                                
                        if last_id:
                            # Datos del registro historico
                            id_laptop = last_id
                            username = linea [9].replace("'","")
                            name = linea [10].replace("'","")
                            id_user_type = linea [6]
                            nif = linea [5].replace("'","")
                            id_state = linea [8]
                                
                            laptopshistory = LaptopsHistory (cdb, "", id_laptop, id_state, id_user_type, nif, username, name, "")
                            laptopshistory.add ()
                            #dbcontrolies.laptops_historical.insert (**attributes)
                                
                    linea = f.readline()

            response.flash = T('Ficheros importados correctamente')        
            session.archivos=[]
        
    return dict(form=form,right_version=right_version)
Beispiel #4
0
def reassignmentSerialNumber():
    serialNumber = request.vars["serial_number"].strip()
    newSerialNumber = request.vars["newSerial"].strip()
    
    l = Laptops(cdb,"","","","","","","","")
            
    if serialNumber!="":
        id_laptop = l.existsSerialNumber(serialNumber)
        unassignmentLaptop(id_laptop)
    
    if newSerialNumber!="":
        userData = getUserData(request.vars["username"])
    
        id_laptop = l.existsSerialNumber(newSerialNumber)
        lh = LaptopsHistory(cdb,"",id_laptop,"2","2",userData["nif"],request.vars["username"],userData["name"],"Reasignado")
        lh.add()

    return dict(response="OK")