Skip to content

Commit

Permalink
Merge pull request #1209 from hanshuaikang/feature/develop_by_han
Browse files Browse the repository at this point in the history
bugfix: 修复导入更新时自动过单不生效的问题
  • Loading branch information
hanshuaikang authored Oct 9, 2023
2 parents 0556133 + 7e35b66 commit d0d7eef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 0 additions & 2 deletions itsm/component/utils/client_backend_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ def get_bk_users(format="list", name_type="bk_username", users=None):
bk_users = cache.get(cache_key)
if not bk_users:
bk_users = update_user_cache(cache_key, format, name_type, users)
# else:
# update_user_cache.delay(cache_key, format, name_type, users)
return bk_users


Expand Down
1 change: 1 addition & 0 deletions itsm/service/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ class WorkflowImportSerializer(serializers.Serializer):
is_iam_used = serializers.BooleanField(required=True)
is_task_needed = serializers.BooleanField(required=True)
is_supervise_needed = serializers.BooleanField(required=True)
is_auto_approve = serializers.BooleanField(required=False)
supervise_type = serializers.ChoiceField(required=True, choices=PROCESSOR_CHOICES)
engine_version = serializers.CharField(required=True)
supervisor = serializers.CharField(
Expand Down
20 changes: 15 additions & 5 deletions itsm/ticket/serializers/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,16 @@ class Meta:
def __init__(self, instance=None, data=empty, **kwargs):
super(TicketSerializer, self).__init__(instance, data, **kwargs)
# 针对批量获取的内容,可以在init的时候进行处理,避免每个数据的序列化都要去拉取接口
self.related_users = self.get_related_users()
self.ticket_followers = self.get_attention_users()

def get_creator_and_current_processors(self, inst):
related_users = self.get_related_users()
creator = transform_single_username(inst.creator, related_users)
current_processors = transform_username(
list(inst.display_current_processors), related_users
)
return creator, current_processors

def get_related_users(self):
"""
获取到所有相关的用户,避免多次访问API接口
Expand Down Expand Up @@ -890,11 +897,11 @@ def to_representation(self, inst):
or inst.can_view(username)
)

creator, current_processors = self.get_creator_and_current_processors(inst)

data.update(
creator=transform_single_username(inst.creator, self.related_users),
current_processors=transform_username(
list(inst.display_current_processors), self.related_users
),
creator=creator,
current_processors=current_processors,
can_comment=can_comment,
can_operate=can_operate,
can_view=can_view,
Expand Down Expand Up @@ -1001,6 +1008,9 @@ class Meta:
) + copy.deepcopy(TicketSerializer.Meta.fields)
read_only_fields = copy.deepcopy(TicketSerializer.Meta.read_only_fields)

def get_creator_and_current_processors(self, inst):
return inst.creator, ",".join(inst.real_current_processors)

def to_representation(self, inst):
"""单据详情"""

Expand Down

0 comments on commit d0d7eef

Please sign in to comment.