some more fixes an formatting changes
This commit is contained in:
		@@ -6,6 +6,7 @@ from django.conf import settings
 | 
				
			|||||||
from django.shortcuts import get_object_or_404
 | 
					from django.shortcuts import get_object_or_404
 | 
				
			||||||
from django.utils import timezone as djangotime
 | 
					from django.utils import timezone as djangotime
 | 
				
			||||||
from django.http import HttpResponse
 | 
					from django.http import HttpResponse
 | 
				
			||||||
 | 
					from rest_framework import serializers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from rest_framework.response import Response
 | 
					from rest_framework.response import Response
 | 
				
			||||||
from rest_framework.views import APIView
 | 
					from rest_framework.views import APIView
 | 
				
			||||||
@@ -189,13 +190,14 @@ class TaskRunner(APIView):
 | 
				
			|||||||
        serializer.is_valid(raise_exception=True)
 | 
					        serializer.is_valid(raise_exception=True)
 | 
				
			||||||
        serializer.save(last_run=djangotime.now())
 | 
					        serializer.save(last_run=djangotime.now())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        new_task = AutomatedTask.objects.get(pk=task.pk)
 | 
				
			||||||
        AuditLog.objects.create(
 | 
					        AuditLog.objects.create(
 | 
				
			||||||
            username=agent.hostname,
 | 
					            username=agent.hostname,
 | 
				
			||||||
            agent=agent.hostname,
 | 
					            agent=agent.hostname,
 | 
				
			||||||
            object_type="agent",
 | 
					            object_type="agent",
 | 
				
			||||||
            action="task_run",
 | 
					            action="task_run",
 | 
				
			||||||
            message=f"Scheduled Task {task.name} was run on {agent.hostname}",
 | 
					            message=f"Scheduled Task {task.name} was run on {agent.hostname}",
 | 
				
			||||||
            after_value=AutomatedTask.serialize(serializer),
 | 
					            after_value=AutomatedTask.serialize(new_task),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return Response("ok")
 | 
					        return Response("ok")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
import datetime as dt
 | 
					import datetime as dt
 | 
				
			||||||
 | 
					import json
 | 
				
			||||||
from abc import abstractmethod
 | 
					from abc import abstractmethod
 | 
				
			||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
from tacticalrmm.middleware import get_username, get_debug_info
 | 
					from tacticalrmm.middleware import get_username, get_debug_info
 | 
				
			||||||
@@ -178,8 +179,12 @@ class AuditLog(models.Model):
 | 
				
			|||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def audit_bulk_action(username, action, affected, debug_info={}):
 | 
					    def audit_bulk_action(username, action, affected, debug_info={}):
 | 
				
			||||||
        from clients.models import Client, Site
 | 
					        from clients.models import Client, Site
 | 
				
			||||||
 | 
					        from agents.models import Agent
 | 
				
			||||||
 | 
					        from scripts.models import Script
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        target = ""
 | 
					        target = ""
 | 
				
			||||||
 | 
					        agents = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if affected["target"] == "all":
 | 
					        if affected["target"] == "all":
 | 
				
			||||||
            target = "on all agents"
 | 
					            target = "on all agents"
 | 
				
			||||||
        elif affected["target"] == "client":
 | 
					        elif affected["target"] == "client":
 | 
				
			||||||
@@ -188,9 +193,19 @@ class AuditLog(models.Model):
 | 
				
			|||||||
        elif affected["target"] == "site":
 | 
					        elif affected["target"] == "site":
 | 
				
			||||||
            site = Site.objects.get(pk=affected["site"])
 | 
					            site = Site.objects.get(pk=affected["site"])
 | 
				
			||||||
            target = f"on all agents within site: {site.client.name}\\{site.name}"
 | 
					            target = f"on all agents within site: {site.client.name}\\{site.name}"
 | 
				
			||||||
        elif affected["target"] == "agent":
 | 
					        elif affected["target"] == "agents":
 | 
				
			||||||
 | 
					            agents = Agent.objects.filter(pk__in=affected["agentPKs"]).values_list(
 | 
				
			||||||
 | 
					                "hostname", flat=True
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
            target = "on multiple agents"
 | 
					            target = "on multiple agents"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if action == "script":
 | 
				
			||||||
 | 
					            script = Script.objects.get(pk=affected["scriptPK"])
 | 
				
			||||||
 | 
					            action = f"script: {script.name}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if agents:
 | 
				
			||||||
 | 
					            affected["agent_hostnames"] = list(agents)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        AuditLog.objects.create(
 | 
					        AuditLog.objects.create(
 | 
				
			||||||
            username=username,
 | 
					            username=username,
 | 
				
			||||||
            object_type="bulk",
 | 
					            object_type="bulk",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -248,7 +248,7 @@ export default {
 | 
				
			|||||||
      objectOptions: [
 | 
					      objectOptions: [
 | 
				
			||||||
        { value: "agent", label: "Agent" },
 | 
					        { value: "agent", label: "Agent" },
 | 
				
			||||||
        { value: "automatedtask", label: "Automated Task" },
 | 
					        { value: "automatedtask", label: "Automated Task" },
 | 
				
			||||||
        { value: "bulk", label: "Bullk Actions" },
 | 
					        { value: "bulk", label: "Bulk Actions" },
 | 
				
			||||||
        { value: "coresettings", label: "Core Settings" },
 | 
					        { value: "coresettings", label: "Core Settings" },
 | 
				
			||||||
        { value: "check", label: "Check" },
 | 
					        { value: "check", label: "Check" },
 | 
				
			||||||
        { value: "client", label: "Client" },
 | 
					        { value: "client", label: "Client" },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user