Updated fetch_price script to store store name

This commit is contained in:
Felipe Martín 2015-09-22 19:39:20 +02:00
parent fa9934bb4d
commit 972bb62197
1 changed files with 10 additions and 10 deletions

View File

@ -13,6 +13,14 @@ from amiibofindr.apps.shop.crawlers import Crawler
class Command(BaseCommand):
def update_product(self, product, region):
amiibo_shop = AmiiboShop.objects.get(
item_id=product['shop_product_id'],
shop__flag_code=region[0]
)
amiibo_shop.shop_name = product.title
amiibo_shop.update_price(product['price'], product['currency'])
def handle(self, *args, **kwargs):
regions = Shop.objects.all()\
.order_by('flag_code')\
@ -27,14 +35,6 @@ class Command(BaseCommand):
products = amazon.fetch_batch(item_codes)
try:
for product in products:
amiibo_shop = AmiiboShop.objects.get(
item_id=product['shop_product_id'],
shop__flag_code=region[0]
)
amiibo_shop.update_price(product['price'], product['currency'])
self.update_product(product, region)
except TypeError:
amiibo_shop = AmiiboShop.objects.get(
item_id=product['shop_product_id'],
shop__flag_code=region[0]
)
amiibo_shop.update_price(product['price'], product['currency'])
self.update_product(product, region)