From a5f123b9ce6879bceca7f85f282a3703c71ed87c Mon Sep 17 00:00:00 2001 From: sadnub Date: Sat, 30 Jan 2021 18:12:09 -0500 Subject: [PATCH] bug fixes with automated manager deleting policies and adding --- api/tacticalrmm/automation/models.py | 17 +++++++---------- .../components/automation/AutomationManager.vue | 3 ++- .../modals/alerts/AlertTemplateAdd.vue | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/api/tacticalrmm/automation/models.py b/api/tacticalrmm/automation/models.py index b2b264cb..94f371ea 100644 --- a/api/tacticalrmm/automation/models.py +++ b/api/tacticalrmm/automation/models.py @@ -25,15 +25,12 @@ class Policy(BaseAuditModel): super(Policy, self).save(*args, **kwargs) # generate agent checks only if active and enforced were changed - if ( - old_policy - and old_policy.active != self.active - or old_policy.enforced != self.enforced - ): - generate_agent_checks_from_policies_task.delay( - policypk=self.pk, - create_tasks=True, - ) + if old_policy: + if old_policy.active != self.active or old_policy.enforced != self.enforced: + generate_agent_checks_from_policies_task.delay( + policypk=self.pk, + create_tasks=True, + ) def delete(self, *args, **kwargs): from automation.tasks import generate_agent_checks_task @@ -41,7 +38,7 @@ class Policy(BaseAuditModel): agents = self.related_agents().values_list("pk", flat=True) super(BaseAuditModel, self).delete(*args, **kwargs) - generate_agent_checks_task.delay(agents, create_tasks=True) + generate_agent_checks_task.delay(list(agents), create_tasks=True) @property def is_default_server_policy(self): diff --git a/web/src/components/automation/AutomationManager.vue b/web/src/components/automation/AutomationManager.vue index 9a8ca619..8def0949 100644 --- a/web/src/components/automation/AutomationManager.vue +++ b/web/src/components/automation/AutomationManager.vue @@ -103,7 +103,7 @@ Copy - + @@ -326,6 +326,7 @@ export default { this.refresh(); this.$q.loading.hide(); this.notifySuccess("Policy was deleted!"); + this.$store.dispatch("loadTree"); }) .catch(error => { this.$q.loading.hide(); diff --git a/web/src/components/modals/alerts/AlertTemplateAdd.vue b/web/src/components/modals/alerts/AlertTemplateAdd.vue index 0fb314b5..dc3a320e 100644 --- a/web/src/components/modals/alerts/AlertTemplateAdd.vue +++ b/web/src/components/modals/alerts/AlertTemplateAdd.vue @@ -58,7 +58,7 @@ export default { methods: { submit() { // close because nothing was edited - if (this.object.alertTemplate === this.selectedTemplate) { + if (this.object.alert_template === this.selectedTemplate) { this.hide(); return; }