fix agent not getting alert template when policies change

This commit is contained in:
sadnub 2022-04-09 23:56:04 -04:00
parent 6b4704b2e2
commit 4c1d2ab1bb
3 changed files with 18 additions and 4 deletions

View File

@ -45,6 +45,8 @@ class Policy(BaseAuditModel):
if old_policy:
if old_policy.alert_template != self.alert_template:
cache_agents_alert_template.delay()
elif old_policy.active != self.active and self.alert_template:
cache_agents_alert_template.delay()
def __str__(self) -> str:
return self.name

View File

@ -56,7 +56,11 @@ class Client(BaseAuditModel):
# check if polcies have changed and initiate task to reapply policies if so
if old_client:
if old_client.alert_template != self.alert_template:
if (
old_client.alert_template != self.alert_template
or old_client.workstation_policy != self.workstation_policy
or old_client.server_policy != self.server_policy
):
cache_agents_alert_template.delay()
class Meta:
@ -129,7 +133,11 @@ class Site(BaseAuditModel):
# check if polcies have changed and initiate task to reapply policies if so
if old_site:
if old_site.alert_template != self.alert_template:
if (
old_site.alert_template != self.alert_template
or old_site.workstation_policy != self.workstation_policy
or old_site.server_policy != self.server_policy
):
cache_agents_alert_template.delay()
class Meta:

View File

@ -107,8 +107,12 @@ class CoreSettings(BaseAuditModel):
old_settings = type(self).objects.get(pk=self.pk) if self.pk else None
super(BaseAuditModel, self).save(*args, **kwargs)
if old_settings and old_settings.alert_template != self.alert_template:
cache_agents_alert_template.delay()
if old_settings:
if (
old_settings.alert_template != self.alert_template
or old_settings.policy != self.policy
):
cache_agents_alert_template.delay()
def __str__(self) -> str:
return "Global Site Settings"