perf: Automation filter org

pull/14614/head
feng 2024-12-06 17:56:10 +08:00 committed by feng626
parent eefda353d2
commit 709b676ec7
1 changed files with 7 additions and 1 deletions

View File

@ -10,10 +10,14 @@ from assets.tasks import execute_asset_automation_task
from common.const.choices import Trigger, Status from common.const.choices import Trigger, Status
from common.db.fields import EncryptJsonDictTextField from common.db.fields import EncryptJsonDictTextField
from ops.mixin import PeriodTaskModelMixin from ops.mixin import PeriodTaskModelMixin
from orgs.mixins.models import OrgModelMixin, JMSOrgBaseModel from orgs.mixins.models import OrgModelMixin, JMSOrgBaseModel, OrgManager
from users.models import User from users.models import User
class BaseAutomationManager(OrgManager):
pass
class BaseAutomation(PeriodTaskModelMixin, JMSOrgBaseModel): class BaseAutomation(PeriodTaskModelMixin, JMSOrgBaseModel):
accounts = models.JSONField(default=list, verbose_name=_("Accounts")) accounts = models.JSONField(default=list, verbose_name=_("Accounts"))
nodes = models.ManyToManyField("assets.Node", blank=True, verbose_name=_("Node")) nodes = models.ManyToManyField("assets.Node", blank=True, verbose_name=_("Node"))
@ -24,6 +28,8 @@ class BaseAutomation(PeriodTaskModelMixin, JMSOrgBaseModel):
is_active = models.BooleanField(default=True, verbose_name=_("Is active")) is_active = models.BooleanField(default=True, verbose_name=_("Is active"))
params = models.JSONField(default=dict, verbose_name=_("Parameters")) params = models.JSONField(default=dict, verbose_name=_("Parameters"))
objects = BaseAutomationManager.from_queryset(models.QuerySet)()
def get_report_template(self): def get_report_template(self):
raise NotImplementedError raise NotImplementedError