def send_order(pedido,proveedor): cliente = pedido['cliente'] print "***************************************************************" print "implement email, or, whatever needed in gip/helper_pedidos.py" print cliente orden = pedido['orden'] print orden precio = pedido['precio'] print precio total = 0.0 u = User.objects.filter(id=pedido['cliente']['user_id']) for i in pedido['orden']: total += orden[i]*precio[i] print total #once that your pedido is ready, you should set all the items as "active" p = Pedidos(producto_serializado=pedido, proveedor_id = proveedor.id, total = total , fecha_creacion = datetime.datetime.now()) p.save() print pedido p.cliente.add(pedido['cliente']['id']) print "***************************************************************" return True
def build_botones(pedido,source): pedido.pedidostate = int(pedido.pedidostate) acciones_tab = '' acciones_modal = '' for t in Pedidos.get_available_pedidostate_transitions(pedido): print "for current pedidostate:" +str(pedido.pedidostate)+ " transistion: "+str(t.name)+" is available" for i in Pedidos.STATE_CHOICES: #TODO: exclide the states that do not want to be seen be the proveedor using my_states if t.target in i: print "we have a target:"+str(t.target)+", and we identifi as "+str(i) if t.target == 12100: acciones_tab += '<a href="#" onclick="show_pedido(\'{0}\')" class="btn btn-info btn-sm" data-toggle="modal">{1}</a> '.format(pedido.id,i[1]) acciones_modal += '<button type="submit" class="btn btn-warning btn-sm" onclick="submit_changes(\'{0}\',\'{1}\')"> Guardar modificaciones</button>'.format(pedido.codigo,pedido.id) elif t.target == 12300: acciones_tab += 'Esperando confirmacion del cliente' else: acciones_tab += '<a href="#" onclick="send(\'{0}\',\'{1}\')" class="btn btn-info btn-sm" data-toggle="modal">{2}</a> '.format(pedido.id,t.name, i[1]) acciones_modal += ' <button type="button" class="btn btn-warning" data-dismiss="modal" onclick="send(\'{0}\',\'{1}\')"> {2}</button> '.format(pedido.id,t.name, i[1]) print "and we have acciones" #we will return accions modal or tab, depend on the source function is request from if source == 'tab': return acciones_tab else: return acciones_modal