Checking history save in diff calc

This commit is contained in:
Felipe Martín 2015-08-29 20:14:43 +02:00
parent 17ae987e62
commit 20f7937e54
2 changed files with 8 additions and 8 deletions

View File

@ -19,8 +19,7 @@ def save_historical_price(sender, instance, **kwargs):
if new_price:
new_price = Decimal(new_price)
if old_price != new_price:
instance.save_history(old_price, new_price)
instance.save_history(old_price, new_price)
def post_check_price_change(sender, instance, created, **kwargs):

View File

@ -228,12 +228,13 @@ class AmiiboPrice(models.Model):
else:
diff = new_price-old_price
history = AmiiboPriceHistory(
amiibo_shop_id=self.amiibo_shop_id,
price=self.price,
currency=self.currency,
diff=diff
)
if diff > 0:
history = AmiiboPriceHistory(
amiibo_shop_id=self.amiibo_shop_id,
price=self.price,
currency=self.currency,
diff=diff
)
return history.save()