π₯π₯π₯ 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
chore: handled the unique state name validation (#6299)
Bavisetti Narayan61d6d928ba6e
diff --git a/apiserver/plane/app/views/state/base.py b/apiserver/plane/app/views/state/base.pyindex 00f4813e68..4c7a73c369 100644--- a/apiserver/plane/app/views/state/base.py+++ b/apiserver/plane/app/views/state/base.py@@ -1,6 +1,9 @@# Python importsfrom itertools import groupby+# Django imports+from django.db.utils import IntegrityError+# Third party importsfrom rest_framework.response import Responsefrom rest_framework import status@@ -37,11 +40,19 @@ class StateViewSet(BaseViewSet):@invalidate_cache(path="workspaces/:slug/states/", url_params=True, user=False)@allow_permission([ROLE.ADMIN])def create(self, request, slug, project_id):- serializer = StateSerializer(data=request.data)- if serializer.is_valid():- serializer.save(project_id=project_id)- return Response(serializer.data, status=status.HTTP_200_OK)- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)+ try:+ serializer = StateSerializer(data=request.data)+ if serializer.is_valid():+ serializer.save(project_id=project_id)+ return Response(serializer.data, status=status.HTTP_200_OK)+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)+ except IntegrityError as e:+ if "already exists" in str(e):+ return Response(+ {"name": "The state name is already taken"},+ status=status.HTTP_400_BAD_REQUEST,+ )+@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])def list(self, request, slug, project_id):