π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
dev: update the response for conflicting errors (#3568)
Nikhil751b15a7a72f
diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.pyindex 7a9cfb1b5c..6f66c373ec 100644--- a/apiserver/plane/api/views/cycle.py+++ b/apiserver/plane/api/views/cycle.py@@ -262,7 +262,7 @@ class CycleAPIEndpoint(WebhookMixin, BaseAPIView):return Response({"error": "Cycle with the same external id and external source already exists",- "cycle": str(cycle.id),+ "id": str(cycle.id),},status=status.HTTP_409_CONFLICT,)@@ -325,7 +325,7 @@ class CycleAPIEndpoint(WebhookMixin, BaseAPIView):return Response({"error": "Cycle with the same external id and external source already exists",- "cycle_id": str(cycle.id),+ "id": str(cycle.id),},status=status.HTTP_409_CONFLICT,)diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.pyindex 530eef5bf4..a759b15f6e 100644--- a/apiserver/plane/api/views/issue.py+++ b/apiserver/plane/api/views/issue.py@@ -239,7 +239,7 @@ class IssueAPIEndpoint(WebhookMixin, BaseAPIView):return Response({"error": "Issue with the same external id and external source already exists",- "issue_id": str(issue.id),+ "id": str(issue.id),},status=status.HTTP_409_CONFLICT,)@@ -286,14 +286,16 @@ class IssueAPIEndpoint(WebhookMixin, BaseAPIView):and Issue.objects.filter(project_id=project_id,workspace__slug=slug,- external_source=request.data.get("external_source", issue.external_source),+ external_source=request.data.get(+ "external_source", issue.external_source+ ),external_id=request.data.get("external_id"),).exists()):return Response({"error": "Issue with the same external id and external source already exists",- "issue_id": str(issue.id),+ "id": str(issue.id),},status=status.HTTP_409_CONFLICT,)@@ -362,6 +364,30 @@ class LabelAPIEndpoint(BaseAPIView):try:serializer = LabelSerializer(data=request.data)if serializer.is_valid():+ if (+ request.data.get("external_id")+ and request.data.get("external_source")+ and Label.objects.filter(+ project_id=project_id,+ workspace__slug=slug,+ external_source=request.data.get("external_source"),+ external_id=request.data.get("external_id"),+ ).exists()+ ):+ label = Label.objects.filter(+ workspace__slug=slug,+ project_id=project_id,+ external_id=request.data.get("external_id"),+ external_source=request.data.get("external_source"),+ ).first()+ return Response(+ {+ "error": "Label with the same external id and external source already exists",+ "id": str(label.id),+ },+ status=status.HTTP_409_CONFLICT,+ )+serializer.save(project_id=project_id)return Response(serializer.data, status=status.HTTP_201_CREATED@@ -370,11 +396,17 @@ class LabelAPIEndpoint(BaseAPIView):serializer.errors, status=status.HTTP_400_BAD_REQUEST)except IntegrityError:+ label = Label.objects.filter(+ workspace__slug=slug,+ project_id=project_id,+ name=request.data.get("name"),+ ).first()return Response({- "error": "Label with the same name already exists in the project"+ "error": "Label with the same name already exists in the project",+ "id": str(label.id),},- status=status.HTTP_400_BAD_REQUEST,+ status=status.HTTP_409_CONFLICT,)def get(self, request, slug, project_id, pk=None):@@ -401,6 +433,25 @@ class LabelAPIEndpoint(BaseAPIView):label = self.get_queryset().get(pk=pk)serializer = LabelSerializer(label, data=request.data, partial=True)if serializer.is_valid():+ if (+ str(request.data.get("external_id"))+ and (label.external_id != str(request.data.get("external_id")))+ and Issue.objects.filter(+ project_id=project_id,+ workspace__slug=slug,+ external_source=request.data.get(+ "external_source", label.external_source+ ),+ external_id=request.data.get("external_id"),+ ).exists()+ ):+ return Response(+ {+ "error": "Label with the same external id and external source already exists",+ "id": str(label.id),+ },+ status=status.HTTP_409_CONFLICT,+ )serializer.save()return Response(serializer.data, status=status.HTTP_200_OK)return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)diff --git a/apiserver/plane/api/views/module.py b/apiserver/plane/api/views/module.pyindex e2d59e126f..d509a53c79 100644--- a/apiserver/plane/api/views/module.py+++ b/apiserver/plane/api/views/module.py@@ -151,7 +151,7 @@ class ModuleAPIEndpoint(WebhookMixin, BaseAPIView):return Response({"error": "Module with the same external id and external source already exists",- "module_id": str(module.id),+ "id": str(module.id),},status=status.HTTP_409_CONFLICT,)@@ -185,7 +185,7 @@ class ModuleAPIEndpoint(WebhookMixin, BaseAPIView):return Response({"error": "Module with the same external id and external source already exists",- "module_id": str(module.id),+ "id": str(module.id),},status=status.HTTP_409_CONFLICT,)diff --git a/apiserver/plane/api/views/state.py b/apiserver/plane/api/views/state.pyindex 88fb083f05..0a262a071d 100644--- a/apiserver/plane/api/views/state.py+++ b/apiserver/plane/api/views/state.py@@ -57,7 +57,7 @@ class StateAPIEndpoint(BaseAPIView):return Response({"error": "State with the same external id and external source already exists",- "state_id": str(state.id),+ "id": str(state.id),},status=status.HTTP_409_CONFLICT,)@@ -128,7 +128,7 @@ class StateAPIEndpoint(BaseAPIView):return Response({"error": "State with the same external id and external source already exists",- "state_id": str(state.id),+ "id": str(state.id),},status=status.HTTP_409_CONFLICT,)