Browse Source

confirm pedidos

David 9 years ago
parent
commit
5106a1d0f5
2 changed files with 9 additions and 0 deletions
  1. 5 0
      back/db.py
  2. 4 0
      back/web.py

+ 5 - 0
back/db.py

@@ -94,3 +94,8 @@ class db():
 		cur.executemany("insert into productos_pedido(id_pedido,id_producto,cantidad) values (%s, %s, %s)", lista_productos)
 		self.conn.commit()
 		return 0
+	
+	def confirm(self, _hash, _id):
+		c = self.client(_hash)
+		cur = self.conn.cursor()
+		cur.execute("UPDATE pedidos set estado = 'CONFIRMADO' where id = %s and cliente = %s and estado = 'CREADO'", (_id,c["id"]))

+ 4 - 0
back/web.py

@@ -49,6 +49,10 @@ def pedido():
 
 	return "{}"
 
+@app.route(BASE_PATH + '/confirm/<_hash>/<pedidoid>', methods=["POST"])
+def confirm(_hash, pedidoid):
+	d.confirm(_hash, pedidoid)
+	return "{}"
 
 if __name__ == '__main__':
 	app.run(host="0.0.0.0",port=PORT, debug=True)