diff --git a/api/tacticalrmm/api/views.py b/api/tacticalrmm/api/views.py index df78c783..24a4d978 100644 --- a/api/tacticalrmm/api/views.py +++ b/api/tacticalrmm/api/views.py @@ -191,6 +191,10 @@ def add(request): else: WinUpdatePolicy(agent=agent).save() + # Generate policies for new agent + agent.generate_checks_from_policies() + agent.generate_tasks_from_policies() + return Response({"pk": agent.pk}) else: return Response("err", status=status.HTTP_400_BAD_REQUEST) diff --git a/api/tacticalrmm/automation/tests.py b/api/tacticalrmm/automation/tests.py index 61347672..904ff884 100644 --- a/api/tacticalrmm/automation/tests.py +++ b/api/tacticalrmm/automation/tests.py @@ -10,13 +10,12 @@ from .serializers import ( AutoTaskPolicySerializer, PolicyOverviewSerializer, PolicyCheckStatusSerializer, + PolicyCheckSerializer, RelatedAgentPolicySerializer, RelatedSitePolicySerializer, RelatedClientPolicySerializer, ) -from checks.serializers import CheckSerializer - from automation.models import Policy from checks.models import Check from autotasks.models import AutomatedTask @@ -128,7 +127,7 @@ class TestPolicyViews(BaseTestCase): url = f"/automation/{self.policy.pk}/policychecks/" resp = self.client.get(url, format="json") - serializer = CheckSerializer([self.policyDiskCheck], many=True) + serializer = PolicyCheckSerializer([self.policyDiskCheck], many=True) self.assertEqual(resp.status_code, 200) self.assertEqual(resp.data, serializer.data)