From e719904874b668e9a127049b55f5994b742915be Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Fri, 15 Sep 2023 11:26:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=8A=A5500=20(#11571)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/tickets/api/comment.py | 1 - apps/tickets/serializers/comment.py | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/tickets/api/comment.py b/apps/tickets/api/comment.py index e9eaf4ac3..3f66663df 100644 --- a/apps/tickets/api/comment.py +++ b/apps/tickets/api/comment.py @@ -9,7 +9,6 @@ from tickets import serializers from tickets.models import Ticket, Comment from tickets.permissions.comment import IsAssignee, IsApplicant, IsSwagger - __all__ = ['CommentViewSet'] diff --git a/apps/tickets/serializers/comment.py b/apps/tickets/serializers/comment.py index 09ce04232..dfee1c84f 100644 --- a/apps/tickets/serializers/comment.py +++ b/apps/tickets/serializers/comment.py @@ -6,14 +6,14 @@ from ..models import Comment __all__ = ['CommentSerializer'] -class CurrentTicket(object): - ticket = None +class CurrentTicket: + requires_context = True - def set_context(self, serializer_field): - self.ticket = serializer_field.context['ticket'] + def __call__(self, serializer_field): + return serializer_field.context['ticket'] - def __call__(self): - return self.ticket + def __repr__(self): + return '%s()' % self.__class__.__name__ class CommentSerializer(serializers.ModelSerializer):