Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 380

Adaptando clases a DAL

Ver diferencias:

controlies/trunk/applications/controlies/modules/LaptopsHistory.py
def list(self,args):
sql = "SELECT id_historical, datetime, state, username, name, comment FROM laptops_historical lh INNER JOIN states s ON lh.id_state=s.id_state"
sql = sql + " WHERE lh.id_laptop='"+str(args["id_laptop"])+"'"
sql = sql + " ORDER BY "+args['sidx']+" "+args['sord']
result = self.DB.executesql(sql)
#sql = "SELECT id_historical, datetime, state, username, name, comment FROM laptops_historical lh INNER JOIN states s ON lh.id_state=s.id_state"
#sql = sql + " WHERE lh.id_laptop='"+str(args["id_laptop"])+"'"
#sql = sql + " ORDER BY "+args['sidx']+" "+args['sord']
import pdb
pdb.set_trace()
#result = self.DB.executesql(sql)
id_laptop = str(args["id_laptop"])
result=self.DB(self.DB.laptops_historical.id_laptop==id_laptop)(self.DB.laptops_historical.id_state==self.DB.states.id_state).select(self.DB.laptops_historical.ALL, self.DB.states.state, orderby=args['sidx']+" "+args['sord'])
rows = []
for reg in result:
d = datetime.datetime.strptime(str(reg[1]), '%Y-%m-%d %H:%M:%S')
d = datetime.datetime.strptime(str(reg['laptops_historical']['datetime']), '%Y-%m-%d %H:%M:%S')
new_dataformat = d.strftime('%d/%m/%Y %H:%M:%S')
row = {
"id":reg[0],
"cell":[new_dataformat,reg[2],reg[3],reg[4],reg[5]],
"id":reg['laptops_historical']['id_historical'],
"cell":[new_dataformat,reg['states']['state'],reg['laptops_historical']['username'],reg['laptops_historical']['name'],reg['laptops_historical']['comment']],
"datetime":new_dataformat,
"state":reg[2],
"username":reg[3],
"name":reg[4],
"comment":reg[5]
"state":reg['states']['state'],
"username":reg['laptops_historical']['username'],
"name":reg['laptops_historical']['name'],
"comment":reg['laptops_historical']['comment']
}
rows.append(row)

Exportar a: Unified diff