Policy Delete Fix
-from django.db.models.signals import post_save, post_delete, m2m_changed
+from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from automation.models import Policy
@@ -32,7 +32,7 @@ def post_save_check_handler(sender, instance, created, **kwargs):
if instance.policy != None:
set_agent_policy_update_field(instance.policy)
-@receiver(post_delete, sender="checks.Check")
+@receiver(pre_delete, sender="checks.Check")
def post_delete_check_handler(sender, instance, **kwargs):
# don't run when policy managed check is saved
@@ -45,7 +45,7 @@ def post_delete_check_handler(sender, instance, **kwargs):
instance.agent.policies_pending=True
instance.agent.save()
-@receiver([post_save, post_delete], sender="automation.Policy")
+@receiver([post_save, pre_delete], sender="automation.Policy")
def post_save_policy_handler(sender, instance, **kwargs):
set_agent_policy_update_field(instance)
