Skip to content

Commit

Permalink
retrieval of price for ripe engine
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 16, 2016
1 parent 17e2ffc commit f787410
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/budy/models/product.py
Expand Up @@ -37,6 +37,8 @@
__license__ = "Apache License, Version 2.0"
""" The license for the module """

import json

import appier

from . import base
Expand Down Expand Up @@ -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"]
Expand All @@ -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"]
Expand Down

0 comments on commit f787410

Please sign in to comment.