make default method post and move imports

This commit is contained in:
wh1te909
2024-06-14 23:53:06 +00:00
parent 5a89d23a67
commit f66afbee90
4 changed files with 59 additions and 24 deletions

View File

@@ -2,16 +2,20 @@ from datetime import timedelta
from itertools import cycle
from unittest.mock import patch
from django.conf import settings
from django.utils import timezone as djangotime
from model_bakery import baker, seq
from alerts.tasks import cache_agents_alert_template
from autotasks.models import TaskResult
from core.tasks import cache_db_fields_task, resolve_alerts_task
from core.utils import get_core_settings
from core.models import URLActionType
from tacticalrmm.constants import AgentMonType, AlertSeverity, AlertType, CheckStatus
from django.conf import settings
from django.utils import timezone as djangotime
from model_bakery import baker, seq
from tacticalrmm.constants import (
AgentMonType,
AlertSeverity,
AlertType,
CheckStatus,
URLActionType,
)
from tacticalrmm.test import TacticalTestCase
from .models import Alert, AlertTemplate

View File

@@ -0,0 +1,28 @@
# Generated by Django 4.2.13 on 2024-06-14 23:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("core", "0046_alter_urlaction_desc_alter_urlaction_name"),
]
operations = [
migrations.AlterField(
model_name="urlaction",
name="rest_method",
field=models.CharField(
choices=[
("get", "Get"),
("post", "Post"),
("put", "Put"),
("delete", "Delete"),
("patch", "Patch"),
],
default="post",
max_length=10,
),
),
]

View File

@@ -10,9 +10,6 @@ from django.contrib.postgres.fields import ArrayField
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.db import models
from twilio.base.exceptions import TwilioRestException
from twilio.rest import Client as TwClient
from logs.models import BaseAuditModel, DebugLog
from tacticalrmm.constants import (
ALL_TIMEZONES,
@@ -20,7 +17,11 @@ from tacticalrmm.constants import (
CustomFieldModel,
CustomFieldType,
DebugLogLevel,
URLActionRestMethod,
URLActionType,
)
from twilio.base.exceptions import TwilioRestException
from twilio.rest import Client as TwClient
if TYPE_CHECKING:
from alerts.models import AlertTemplate
@@ -449,28 +450,17 @@ class GlobalKVStore(BaseAuditModel):
return KeyStoreSerializer(store).data
class URLActionType(models.TextChoices):
WEB = "web", "Web"
REST = "rest", "Rest"
class URLActionRestMethod(models.TextChoices):
GET = "get", "Get"
POST = "post", "Post"
PUT = "put", "Put"
DELETE = "delete", "Delete"
PATCH = "patch", "Patch"
class URLAction(BaseAuditModel):
name = models.CharField(max_length=255)
desc = models.TextField(null=True, blank=True)
pattern = models.TextField()
action_type = models.CharField(
max_length=10, choices=URLActionType.choices, default="web"
max_length=10, choices=URLActionType.choices, default=URLActionType.WEB
)
rest_method = models.CharField(
max_length=10, choices=URLActionRestMethod.choices, default="get"
max_length=10,
choices=URLActionRestMethod.choices,
default=URLActionRestMethod.POST,
)
rest_body = models.TextField(null=True, blank=True, default="")
rest_headers = models.TextField(null=True, blank=True, default="")

View File

@@ -253,6 +253,19 @@ class DebugLogType(models.TextChoices):
SCRIPTING = "scripting", "Scripting"
class URLActionType(models.TextChoices):
WEB = "web", "Web"
REST = "rest", "Rest"
class URLActionRestMethod(models.TextChoices):
GET = "get", "Get"
POST = "post", "Post"
PUT = "put", "Put"
DELETE = "delete", "Delete"
PATCH = "patch", "Patch"
# Agent db fields that are not needed for most queries, speeds up query
AGENT_DEFER = (
"wmi_detail",