From bd7a1295342ca1de429b266b868e918fd36be9c7 Mon Sep 17 00:00:00 2001 From: QSummerY <1272750872@qq.com> Date: Tue, 7 Feb 2023 11:23:19 +0800 Subject: [PATCH] add app approvers check before create ticket --- helpdesk/models/action.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpdesk/models/action.py b/helpdesk/models/action.py index 58ea237c..555f4817 100644 --- a/helpdesk/models/action.py +++ b/helpdesk/models/action.py @@ -6,6 +6,7 @@ from helpdesk.libs.rest import DictSerializableClassMixin from helpdesk.models.db.ticket import Ticket, TicketPhase from helpdesk.config import AUTO_APPROVAL_TARGET_OBJECTS, PARAM_FILLUP, TICKET_CALLBACK_PARAMS +from helpdesk.views.api.schemas import ApproverType logger = logging.getLogger(__name__) @@ -102,7 +103,10 @@ async def run(self, provider, form, user): ticket.annotate(policy=policy.name) ticket.annotate(current_node=policy.init_node.get("name")) ticket.annotate(approval_log=list()) - ticket.annotate(approvers=await ticket.get_node_approvers(policy.init_node.get("name"))) + approvers = await ticket.get_node_approvers(policy.init_node.get("name")) + if not approvers and policy.init_node.get("approver_type") == ApproverType.APP_OWNER: + return None, "Failed to get app approvers, please confirm that the app name is entered correctly" + ticket.annotate(approvers=approvers) ret, msg = await ticket.pre_approve() if not ret: