diff --git a/config/default.py b/config/default.py index 9f4c877f..fccdd17c 100644 --- a/config/default.py +++ b/config/default.py @@ -50,7 +50,7 @@ # 针对 paas_v3 容器化差异化配置 ENGINE_REGION = os.environ.get("BKPAAS_ENGINE_REGION", "open") -if ENGINE_REGION == "default": +if ENGINE_REGION == "default" and RUN_VER != "ieod": env_settings = importlib.import_module("adapter.config.sites.%s.env" % "v3") for _setting in dir(env_settings): if _setting.upper() == _setting: diff --git a/config/dev.py b/config/dev.py index 4b0f495b..42d59e80 100644 --- a/config/dev.py +++ b/config/dev.py @@ -76,7 +76,7 @@ # 针对 paas_v3 容器化铺垫 ENGINE_REGION = os.environ.get("BKPAAS_ENGINE_REGION", "open") -if ENGINE_REGION == "default": +if ENGINE_REGION == "default" and RUN_VER != "ieod" : default_settings = importlib.import_module( "adapter.config.sites.%s.ver_settings" % "v3" ) diff --git a/config/prod.py b/config/prod.py index e169845d..ae385a7b 100644 --- a/config/prod.py +++ b/config/prod.py @@ -109,7 +109,7 @@ # 如果是容器化环境,则覆盖配置 ENGINE_REGION = os.environ.get("BKPAAS_ENGINE_REGION", "open") -if ENGINE_REGION == "default": +if ENGINE_REGION == "default" and RUN_VER != "ieod": default_settings = importlib.import_module( "adapter.config.sites.%s.ver_settings" % "v3" ) diff --git a/config/stag.py b/config/stag.py index da6c85c9..97f2dcfc 100644 --- a/config/stag.py +++ b/config/stag.py @@ -96,7 +96,7 @@ locals()[_setting] = getattr(ver_settings, _setting) ENGINE_REGION = os.environ.get("BKPAAS_ENGINE_REGION", "open") -if ENGINE_REGION == "default": +if ENGINE_REGION == "default" and RUN_VER != "ieod": default_settings = importlib.import_module( "adapter.config.sites.%s.ver_settings" % "v3" ) diff --git a/itsm/ticket/views/ticket.py b/itsm/ticket/views/ticket.py index 7971958e..a3a434c9 100644 --- a/itsm/ticket/views/ticket.py +++ b/itsm/ticket/views/ticket.py @@ -368,7 +368,6 @@ def create(self, request, *args, **kwargs): serializer.is_valid(raise_exception=True) data = serializer.validated_data service = Service.objects.get(id=data["service_id"]) - print("----- create ticket get service") # 是否开启代提单 meta = data.get("meta", {}) @@ -379,13 +378,16 @@ def create(self, request, *args, **kwargs): # creator(实际提单人)和updated_by在serializer.to_internal_value(data)中获取 instance = serializer.save(meta=meta) - print("----- create ticket do_after_create begin") + logger.info(f"[TICKET] create ticket do_after_create begin ticket_id=>{instance.id}") + instance.do_after_create( request.data["fields"], request.data.get("from_ticket_id", None) ) - print("----- create ticket do_after_create end") + logger.info(f"[TICKET] create ticket do_after_create end ticket_id=>{instance.id}") + start_pipeline.apply_async([instance]) - print("----- create ticket start_pipeline end") + logger.info(f"[TICKET] create ticket start_pipeline end ticket_id=>{instance.id}") + return Response({"sn": instance.sn, "id": instance.id}, status=201) @action(detail=True, methods=["get"]) diff --git a/itsm/trigger/permissions.py b/itsm/trigger/permissions.py index a952b4c2..15c3a28b 100644 --- a/itsm/trigger/permissions.py +++ b/itsm/trigger/permissions.py @@ -87,9 +87,6 @@ def has_object_permission(self, request, view, obj, **kwargs): is_workflow = False workflow_id = None if obj.source_type == SOURCE_WORKFLOW: - is_workflow = True - workflow_id = request.data.get("source_id") - elif obj.source_type == SOURCE_WORKFLOW: is_workflow = True workflow_id = obj.source_id @@ -97,6 +94,12 @@ def has_object_permission(self, request, view, obj, **kwargs): workflow = Workflow.objects.get(id=workflow_id) apply_actions = ["service_manage"] return self.iam_auth(request, apply_actions, workflow.get_iam_resource()) + + # 通过任务模板创建 + if obj.source_type == SOURCE_TASK: + apply_actions = ["public_task_template_manage"] + return self.iam_auth(request, apply_actions) + apply_actions = ["triggers_manage"] return self.iam_auth(request, apply_actions, obj)