def get(self): product_id = self.get_argument("product_id", "") vote = Vote() response = vote.GetVotes(product_id) self.write(json_util.dumps(response))
def get(self, category, name, color): category = category.replace("_", "&") name = name.replace("_", "&") color = color.replace("_", "&") tag = self.get_argument("tag", "") id_bodega = cellar_id cellar = Cellar() res_cellar = cellar.GetWebCellar() if "success" in res_cellar: id_bodega = res_cellar["success"] # sku = self.get_argument("sku","") prod = Product() response_obj = prod.GetProductCatNameColor(category, name, color) if "error" in response_obj: self.render("beauty_error.html", message="Producto no encontrado, error:{}".format( response_obj["error"])) else: tallas_disponibles = [] prod.size_id = sorted(prod.size_id, reverse=True) for s in prod.size_id: kardex = Kardex() response_obj = kardex.FindKardex(prod.sku, id_bodega, s) if "success" in response_obj: # print kardex.balance_units if kardex.balance_units > 0: _size = Size() _size.id = s res_name = _size.initById() if "success" in res_name: tallas_disponibles.append({ "id": _size.id, "name": _size.name, "stock": kardex.balance_units }) elif debugMode: print res_name["error"] elif debugMode: print response_obj["error"] prod.size = tallas_disponibles[::-1] vote = Vote() res = vote.GetVotes(prod.id) votos = 0 prod_name = prod.name try: prod_name = name.split("&")[0] except: pass # print "prod_name:{}".format(prod_name) combinaciones = prod.GetCombinations(id_bodega, prod_name) tag = Tag() res_tags = tag.GetTagsByProductId(prod.id) if "success" in res_tags: relacionados = prod.GetRandom(id_bodega, res_tags["success"]) if "success" in res: votos = res["success"] self.render("store/detalle-producto.html", data=prod, combinations=combinaciones, related=relacionados, votos=votos, tag=tag)