def cost_post_save(sender, instance, raw, using, **kwargs): changed = False if 'venture_id' in instance.dirty_fields: changed = True if 'expire' in instance.dirty_fields: changed = True if 'cost' in instance.dirty_fields: old_cost = instance.dirty_fields['cost'] or 0 if not -1 < instance.cost - old_cost < 1: # Ignore changes due to rounding errors changed = True if changed: HistoryCost.start_span(extra=instance, end=instance.expire)
def cost_post_save(sender, instance, raw, using, **kwargs): changed = False if 'venture_id' in instance.dirty_fields: changed = True if 'expire' in instance.dirty_fields: changed = True if 'cost' in instance.dirty_fields: old_cost = instance.dirty_fields['cost'] or 0 if not -1 < instance.cost - old_cost < 1: # Ignore changes due to rounding errors changed = True if changed: if instance.expire: start = min(datetime.date.today(), instance.expire) else: start = datetime.datetime.now() HistoryCost.start_span(extra=instance, start=start, end=instance.expire)