Improvements on orders

This commit is contained in:
Marc 2014-07-18 15:36:32 +00:00
parent 56651a154e
commit f165e5ffda
1 changed files with 4 additions and 11 deletions

View File

@ -242,7 +242,6 @@ class MetricStorage(models.Model):
return self.order return self.order
@receiver(pre_delete, dispatch_uid="orders.cancel_orders") @receiver(pre_delete, dispatch_uid="orders.cancel_orders")
def cancel_orders(sender, **kwargs): def cancel_orders(sender, **kwargs):
if not sender in [MetricStorage, LogEntry, Order, Service]: if not sender in [MetricStorage, LogEntry, Order, Service]:
@ -251,19 +250,13 @@ def cancel_orders(sender, **kwargs):
order.cancel() order.cancel()
@receiver(post_delete, dispatch_uid="orders.update_orders_on_delete")
def update_orders_on_delete(sender, **kwargs):
if not sender in [MetricStorage, LogEntry, Order, Service]:
instance = kwargs['instance']
related = search_for_related(instance)
if related:
Order.update_orders(related)
@receiver(post_save, dispatch_uid="orders.update_orders") @receiver(post_save, dispatch_uid="orders.update_orders")
@receiver(post_delete, dispatch_uid="orders.update_orders")
def update_orders(sender, **kwargs): def update_orders(sender, **kwargs):
if not sender in [MetricStorage, LogEntry, Order, Service]: if not sender in [MetricStorage, LogEntry, Order, Service]:
instance = kwargs['instance'] instance = kwargs['instance']
if instance.pk:
# post_save
Order.update_orders(instance) Order.update_orders(instance)
related = search_for_related(instance) related = search_for_related(instance)
if related: if related: