Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 节点支持配置审批结果为拒绝时自动终止单据 #1253

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions itsm/pipeline_plugins/components/collections/itsm_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import logging

from itsm.component.constants import NODE_APPROVE_RESULT
from itsm.component.constants import NODE_APPROVE_RESULT, TERMINATED
from itsm.ticket.models import Ticket, Status, TicketGlobalVariable, SignTask
from pipeline.component_framework.component import Component

Expand Down Expand Up @@ -88,12 +88,12 @@ def schedule(self, data, parent_data, callback_data=None):
operator = callback_data["operator"]
fields = callback_data["fields"]
source = callback_data["source"]

variables = data.outputs.get("variables")
finish_condition = data.outputs.get("finish_condition")
code_key = data.outputs.get("code_key")
ticket = Ticket.objects.get(id=ticket_id)
node_status = Status.objects.get(ticket_id=ticket_id, state_id=state_id)
state = ticket.state(state_id)

try:
ticket.do_in_sign_state(node_status, fields, operator, source)
Expand All @@ -117,6 +117,15 @@ def schedule(self, data, parent_data, callback_data=None):
data.set_outputs("params_%s" % field["key"], field["value"])

self.do_before_exit(ticket, state_id, operator)
if key_value[
code_key[NODE_APPROVE_RESULT]
] == "false" and state.get(
"enable_terminate_ticket_when_rejected", False
):
logger.info(
"[sign] enable_terminate_ticket_when_rejected is true ticket closed"
)
ticket.close(close_status=TERMINATED, operator="system")
self.finish_schedule()
finally:
self.final_execute(node_status, operator)
Expand Down
2 changes: 1 addition & 1 deletion itsm/ticket/models/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ def set_finished(
# TODO: 临时处理, 后面会放在母子单解绑逻辑中
ticket.current_status = close_status
ticket.node_status.filter(status__in=Status.RUNNING_STATUS).update(
status=FINISHED
status=close_status
)
ticket.current_task_processors = ""
ticket.current_processors = ""
Expand Down
Loading