2525from knowledge .serializers .common import BatchSerializer
2626from maxkb .conf import PROJECT_DIR
2727from tools .models import Tool
28- from trigger .handler .simple_tools import deploy , undeploy
2928from trigger .models import TriggerTypeChoices , Trigger , TriggerTaskTypeChoices , TriggerTask , TaskRecord
3029
3130
@@ -397,6 +396,8 @@ def is_valid(self, *, raise_exception=False):
397396
398397 @transaction .atomic
399398 def batch_delete (self , instance : Dict , with_valid = True ):
399+ from trigger .handler .simple_tools import deploy , undeploy
400+
400401 if with_valid :
401402 BatchSerializer (data = instance ).is_valid (model = Trigger , raise_exception = True )
402403 self .is_valid (raise_exception = True )
@@ -414,6 +415,8 @@ def batch_delete(self, instance: Dict, with_valid=True):
414415
415416 @transaction .atomic
416417 def batch_switch (self , instance : Dict , with_valid = True ):
418+ from trigger .handler .simple_tools import deploy , undeploy
419+
417420 if with_valid :
418421 BatchActiveSerializer (data = instance ).is_valid (model = Trigger , raise_exception = True )
419422 self .is_valid (raise_exception = True )
@@ -450,6 +453,8 @@ def is_valid(self, *, raise_exception=False):
450453
451454 @transaction .atomic
452455 def edit (self , instance : Dict , with_valid = True ):
456+ from trigger .handler .simple_tools import deploy , undeploy
457+
453458 if with_valid :
454459 self .is_valid ()
455460 TriggerEditRequest (data = instance ).is_valid (raise_exception = True )
@@ -488,6 +493,8 @@ def edit(self, instance: Dict, with_valid=True):
488493 return self .one (with_valid = False )
489494
490495 def delete (self ):
496+ from trigger .handler .simple_tools import deploy , undeploy
497+
491498 self .is_valid (raise_exception = True )
492499 trigger_id = self .data .get ('trigger_id' )
493500 trigger = QuerySet (Trigger ).filter (workspace_id = self .data .get ('workspace_id' ), id = trigger_id ).first ()
0 commit comments