From f7874109c59764c110254ae4061f038effe56a35 Mon Sep 17 00:00:00 2001 From: joamag Date: Wed, 16 Mar 2016 14:39:17 +0000 Subject: [PATCH] retrieval of price for ripe engine --- src/budy/models/product.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/budy/models/product.py b/src/budy/models/product.py index 9e6806bb..e653b4af 100644 --- a/src/budy/models/product.py +++ b/src/budy/models/product.py @@ -37,6 +37,8 @@ __license__ = "Apache License, Version 2.0" """ The license for the module """ +import json + import appier from . import base @@ -265,15 +267,16 @@ def callback(line): cls._csv_import(file, callback) - def get_price(self, attributes = {}): + def get_price(self, attributes = None): if not self.price_provider: return self.price - method = getattr(self, "build_price_%s" % self.price_provider) + method = getattr(self, "get_price_%s" % self.price_provider) return method(attributes = attributes) - def get_price_ripe(self, attributes = {}): + def get_price_ripe(self, attributes = None): if not self.price_url: return self.price + attributes_m = json.loads(attributes) p = [] - parts = attributes.get("parts", {}) + parts = attributes_m.get("parts", {}) for key, value in appier.legacy.iteritems(parts): material = value["material"] color = value["color"] @@ -284,7 +287,7 @@ def get_price_ripe(self, attributes = {}): self.price_url, params = dict( product_id = self.product_id, - p = parts + p = p ) ) total = result["total"]