From f165e5ffda858fa4930d59312456bfd564a74c25 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 18 Jul 2014 15:36:32 +0000 Subject: [PATCH] Improvements on orders --- orchestra/apps/orders/models.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/orchestra/apps/orders/models.py b/orchestra/apps/orders/models.py index 3ef47979..b52ef564 100644 --- a/orchestra/apps/orders/models.py +++ b/orchestra/apps/orders/models.py @@ -242,7 +242,6 @@ class MetricStorage(models.Model): return self.order - @receiver(pre_delete, dispatch_uid="orders.cancel_orders") def cancel_orders(sender, **kwargs): if not sender in [MetricStorage, LogEntry, Order, Service]: @@ -251,20 +250,14 @@ def cancel_orders(sender, **kwargs): 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_delete, dispatch_uid="orders.update_orders") def update_orders(sender, **kwargs): if not sender in [MetricStorage, LogEntry, Order, Service]: instance = kwargs['instance'] - Order.update_orders(instance) + if instance.pk: + # post_save + Order.update_orders(instance) related = search_for_related(instance) if related: Order.update_orders(related)