Added check_price parameter

This commit is contained in:
Felipe Martín 2015-07-09 13:02:07 +02:00
parent 175b0a60ed
commit 63fc166eea
4 changed files with 27 additions and 2 deletions

View File

@ -14,10 +14,15 @@ from amiibofindr.apps.shop.crawlers import Crawler
class Command(BaseCommand):
def handle(self, *args, **kwargs):
regions = Shop.objects.all().order_by('flag_code').distinct('flag_code').values_list('flag_code', 'slug')
regions = Shop.objects.all()\
.order_by('flag_code')\
.distinct('flag_code')\
.values_list('flag_code', 'slug')
for region in regions:
item_codes = AmiiboShop.objects.filter(shop__flag_code=region[0]).values_list('item_id', flat=True)
item_codes = AmiiboShop.objects.filter(
shop__flag_code=region[0],
check_price=True).values_list('item_id', flat=True)
amazon = Crawler(region[1])
products = amazon.fetch_batch(item_codes)
for product in products:

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('amiibo', '0017_auto_20150625_1806'),
]
operations = [
migrations.AddField(
model_name='amiiboshop',
name='check_price',
field=models.BooleanField(default=True),
),
]

View File

@ -104,6 +104,7 @@ class AmiiboShop(models.Model):
shop = models.ForeignKey('shop.Shop', related_name='amiibos_set')
url = models.TextField()
item_id = models.CharField(max_length=64)
check_price = models.BooleanField(default=True)
class Meta:
ordering = ('shop__name', )

BIN
amiibofindr/db.sqlite3 Normal file

Binary file not shown.