Skip to content

Commit

Permalink
fix: 修复触发器创建异常 --story=119997066 (#1434)
Browse files Browse the repository at this point in the history
  • Loading branch information
benero authored Oct 10, 2024
1 parent adef885 commit 1a30acb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion config/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion config/stag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
10 changes: 6 additions & 4 deletions itsm/ticket/views/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {})
Expand All @@ -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"])
Expand Down
9 changes: 6 additions & 3 deletions itsm/trigger/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,19 @@ 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

if is_workflow:
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)

0 comments on commit 1a30acb

Please sign in to comment.