From c29dae8eb0202a5f0d88422fefd0d7c8cefa2645 Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Tue, 14 May 2024 10:21:27 +0530 Subject: [PATCH] Show chat's feedbacks (#512) * show chats feedbacks filtered * return queryset as response --- ayushma/views/chat.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ayushma/views/chat.py b/ayushma/views/chat.py index 0a76686..4c7818d 100644 --- a/ayushma/views/chat.py +++ b/ayushma/views/chat.py @@ -49,6 +49,7 @@ class ChatViewSet( "list_all": ChatDetailSerializer, "converse": ConverseSerializer, "speech_to_text": SpeechToTextSerializer, + "feedbacks": ChatFeedbackSerializer, } permission_classes = (IsTempTokenOrAuthenticated,) lookup_field = "external_id" @@ -98,6 +99,18 @@ def perform_create(self, serializer): serializer.save(user=self.request.user, project=project) super().perform_create(serializer) + @extend_schema( + tags=("chats",), + ) + @action(detail=True, methods=["get"]) + def feedbacks(self, *args, **kwarg): + q = ChatFeedback.objects.filter(chat_message__chat__external_id=kwarg["external_id"]) + serialized_data = ChatFeedbackSerializer(q, many=True).data + return Response( + {"data": serialized_data}, + status=status.HTTP_200_OK, + ) + @extend_schema( tags=("chats",), )