From d2cdaaccb9e7b2884c66d7ce72d27ce36a66d4e8 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:53:09 +0530 Subject: [PATCH] fix: slack queryset (#1860) --- apiserver/plane/api/views/integration/slack.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/api/views/integration/slack.py b/apiserver/plane/api/views/integration/slack.py index 06e2dfe39..498dd0607 100644 --- a/apiserver/plane/api/views/integration/slack.py +++ b/apiserver/plane/api/views/integration/slack.py @@ -20,6 +20,17 @@ class SlackProjectSyncViewSet(BaseViewSet): serializer_class = SlackProjectSyncSerializer model = SlackProjectSync + def get_queryset(self): + return ( + super() + .get_queryset() + .filter( + workspace__slug=self.kwargs.get("slug"), + project_id=self.kwargs.get("project_id"), + ) + .filter(project__project_projectmember__member=self.request.user) + ) + def create(self, request, slug, project_id, workspace_integration_id): try: serializer = SlackProjectSyncSerializer(data=request.data) @@ -45,7 +56,10 @@ class SlackProjectSyncViewSet(BaseViewSet): return Response(serializer.data, status=status.HTTP_200_OK) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) except IntegrityError: - return Response({"error": "Slack is already enabled for the project"}, status=status.HTTP_400_BAD_REQUEST) + return Response( + {"error": "Slack is already enabled for the project"}, + status=status.HTTP_400_BAD_REQUEST, + ) except WorkspaceIntegration.DoesNotExist: return Response( {"error": "Workspace Integration does not exist"},