From a019e6bd11662e8d518c8473b96d69485c40120c Mon Sep 17 00:00:00 2001 From: blackholll Date: Thu, 2 Aug 2018 06:54:37 +0800 Subject: [PATCH] bugfix: when next state participant is ticket field, and handle submit contain this field. loonflow Can not get ticket'next participant --- service/ticket/ticket_base_service.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/service/ticket/ticket_base_service.py b/service/ticket/ticket_base_service.py index 20564583..a3d6c480 100644 --- a/service/ticket/ticket_base_service.py +++ b/service/ticket/ticket_base_service.py @@ -322,7 +322,7 @@ def get_ticket_format_custom_field_key_dict(cls, ticket_id): custom_field_queryset = CustomField.objects.filter(is_deleted=0, workflow_id=ticket_obj.workflow_id).all() format_field_key_dict = {} for custom_field in custom_field_queryset: - format_field_key_dict[custom_field.field_key] = dict(field_type_id=custom_field.field_type_id, name=custom_field.field_name, placeholder=custom_field.placeholder, bool_field_display=custom_field.bool_field_display, + format_field_key_dict[custom_field.field_key] = dict(field_type_id=custom_field.field_type_id, name=custom_field.field_name, bool_field_display=custom_field.boolean_field_display, field_choice=custom_field.field_choice, field_from='custom') return format_field_key_dict, '' @@ -385,7 +385,7 @@ def get_ticket_field_name(cls, ticket_id, field_key): :return: """ if field_key in CONSTANT_SERVICE.TICKET_BASE_FIELD_LIST: - pass + return field_key, '' else: field_name, msg = cls.get_ticket_custom_field_name(ticket_id, field_key) @@ -401,7 +401,8 @@ def get_ticket_custom_field_name(cls, ticket_id, field_key): :return: """ format_field_key_dict, msg = cls.get_ticket_format_custom_field_key_dict(ticket_id) - field_name = format_field_key_dict['field_key']['field_name'] + field_name = format_field_key_dict[field_key]['field_name'] + return field_name, '' @classmethod @@ -870,9 +871,12 @@ def handle_ticket(cls, ticket_id, request_data_dict): add_relation = ','.join(username_list) elif destination_participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_FIELD: # 获取工单字段的值 - field_value, msg = cls.get_ticket_field_value(ticket_id, destination_participant) + # 考虑到处理工单时 可能会编辑工单字段,所有优先从请求数据中获取,如果没有再去数据库中获取 + field_value = request_data_dict.get('destination_participant') if not field_value: - return False, msg + field_value, msg = cls.get_ticket_field_value(ticket_id, destination_participant) + if not field_value: + return False, msg destination_participant = field_value destination_participant_type_id = CONSTANT_SERVICE.PARTICIPANT_TYPE_PERSONAL add_relation = destination_participant