From c5f4ecc8cc910449eb0d446597347029b75504f9 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Tue, 14 Sep 2021 15:48:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/acls/api/login_asset_check.py | 7 +++---- apps/assets/api/cmd_filter.py | 7 +++---- apps/tickets/utils.py | 12 +++++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/acls/api/login_asset_check.py b/apps/acls/api/login_asset_check.py index ee2fba4d5..2adee4604 100644 --- a/apps/acls/api/login_asset_check.py +++ b/apps/acls/api/login_asset_check.py @@ -9,12 +9,11 @@ from tickets.api import GenericTicketStatusRetrieveCloseAPI from ..models import LoginAssetACL from .. import serializers - __all__ = ['LoginAssetCheckAPI', 'LoginAssetConfirmStatusAPI'] class LoginAssetCheckAPI(CreateAPIView): - permission_classes = (IsAppUser, ) + permission_classes = (IsAppUser,) serializer_class = serializers.LoginAssetCheckSerializer def create(self, request, *args, **kwargs): @@ -57,11 +56,12 @@ class LoginAssetCheckAPI(CreateAPIView): external=True, api_to_ui=True ) ticket_detail_url = '{url}?type={type}'.format(url=ticket_detail_url, type=ticket.type) + ticket_assignees = ticket.current_node.first().ticket_assignees.all() data = { 'check_confirm_status': {'method': 'GET', 'url': confirm_status_url}, 'close_confirm': {'method': 'DELETE', 'url': confirm_status_url}, 'ticket_detail_url': ticket_detail_url, - 'reviewers': [str(user) for user in ticket.current_node.first().ticket_assignees.all()], + 'reviewers': [str(ticket_assignee.assignee) for ticket_assignee in ticket_assignees] } return data @@ -74,4 +74,3 @@ class LoginAssetCheckAPI(CreateAPIView): class LoginAssetConfirmStatusAPI(GenericTicketStatusRetrieveCloseAPI): pass - diff --git a/apps/assets/api/cmd_filter.py b/apps/assets/api/cmd_filter.py index 948300d93..d7ed099ed 100644 --- a/apps/assets/api/cmd_filter.py +++ b/apps/assets/api/cmd_filter.py @@ -13,7 +13,6 @@ from ..hands import IsOrgAdmin, IsAppUser from ..models import CommandFilter, CommandFilterRule from .. import serializers - __all__ = [ 'CommandFilterViewSet', 'CommandFilterRuleViewSet', 'CommandConfirmAPI', 'CommandConfirmStatusAPI' @@ -44,7 +43,7 @@ class CommandFilterRuleViewSet(OrgBulkModelViewSet): class CommandConfirmAPI(CreateAPIView): - permission_classes = (IsAppUser, ) + permission_classes = (IsAppUser,) serializer_class = serializers.CommandConfirmSerializer def create(self, request, *args, **kwargs): @@ -73,11 +72,12 @@ class CommandConfirmAPI(CreateAPIView): external=True, api_to_ui=True ) ticket_detail_url = '{url}?type={type}'.format(url=ticket_detail_url, type=ticket.type) + ticket_assignees = ticket.current_node.first().ticket_assignees.all() return { 'check_confirm_status': {'method': 'GET', 'url': confirm_status_url}, 'close_confirm': {'method': 'DELETE', 'url': confirm_status_url}, 'ticket_detail_url': ticket_detail_url, - 'reviewers': [str(user) for user in ticket.current_node.first().ticket_assignees.all()] + 'reviewers': [str(ticket_assignee.assignee) for ticket_assignee in ticket_assignees] } @lazyproperty @@ -89,4 +89,3 @@ class CommandConfirmAPI(CreateAPIView): class CommandConfirmStatusAPI(GenericTicketStatusRetrieveCloseAPI): pass - diff --git a/apps/tickets/utils.py b/apps/tickets/utils.py index 18de23371..66edb3828 100644 --- a/apps/tickets/utils.py +++ b/apps/tickets/utils.py @@ -9,13 +9,15 @@ logger = get_logger(__file__) def send_ticket_applied_mail_to_assignees(ticket): - assignees = ticket.current_node.first().ticket_assignees.all() - if not assignees: - logger.debug("Not found assignees, ticket: {}({}), assignees: {}".format(ticket, str(ticket.id), assignees)) + ticket_assignees = ticket.current_node.first().ticket_assignees.all() + if not ticket_assignees: + logger.debug( + "Not found assignees, ticket: {}({}), assignees: {}".format(ticket, str(ticket.id), ticket_assignees) + ) return - for assignee in assignees: - instance = TicketAppliedToAssignee(assignee, ticket) + for ticket_assignee in ticket_assignees: + instance = TicketAppliedToAssignee(ticket_assignee.assignee, ticket) if settings.DEBUG: logger.debug(instance) instance.publish_async()