π₯π₯π₯ 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
[WEB-2129] fix: module creation and updation toast error (#5550)
Ketan Sharma29fd1186eed5
diff --git a/apiserver/plane/api/serializers/module.py b/apiserver/plane/api/serializers/module.pyindex a768cd26c6..c1a0c577db 100644--- a/apiserver/plane/api/serializers/module.py+++ b/apiserver/plane/api/serializers/module.py@@ -71,6 +71,16 @@ class ModuleSerializer(BaseSerializer):project_id = self.context["project_id"]workspace_id = self.context["workspace_id"]+ module_name = validated_data.get("name")+ if module_name:+ # Lookup for the module name in the module table for that project+ if Module.objects.filter(+ name=module_name, project_id=project_id+ ).exists():+ raise serializers.ValidationError(+ {"error": "Module with this name already exists"}+ )+module = Module.objects.create(**validated_data, project_id=project_id)if members is not None:ModuleMember.objects.bulk_create(@@ -93,6 +103,19 @@ class ModuleSerializer(BaseSerializer):def update(self, instance, validated_data):members = validated_data.pop("members", None)+ module_name = validated_data.get("name")+ if module_name:+ # Lookup for the module name in the module table for that project+ if (+ Module.objects.filter(+ name=module_name, project=instance.project+ )+ .exclude(id=instance.id)+ .exists()+ ):+ raise serializers.ValidationError(+ {"error": "Module with this name already exists"}+ )if members is not None:ModuleMember.objects.filter(module=instance).delete()diff --git a/apiserver/plane/app/serializers/module.py b/apiserver/plane/app/serializers/module.pyindex fc228b6b96..48ace60222 100644--- a/apiserver/plane/app/serializers/module.py+++ b/apiserver/plane/app/serializers/module.py@@ -68,6 +68,16 @@ class ModuleWriteSerializer(BaseSerializer):members = validated_data.pop("member_ids", None)project = self.context["project"]+ module_name = validated_data.get("name")+ if module_name:+ # Lookup for the module name in the module table for that project+ if Module.objects.filter(+ name=module_name, project=project+ ).exists():+ raise serializers.ValidationError(+ {"error": "Module with this name already exists"}+ )+module = Module.objects.create(**validated_data, project=project)if members is not None:ModuleMember.objects.bulk_create(@@ -90,6 +100,19 @@ class ModuleWriteSerializer(BaseSerializer):def update(self, instance, validated_data):members = validated_data.pop("member_ids", None)+ module_name = validated_data.get("name")+ if module_name:+ # Lookup for the module name in the module table for that project+ if (+ Module.objects.filter(+ name=module_name, project=instance.project+ )+ .exclude(id=instance.id)+ .exists()+ ):+ raise serializers.ValidationError(+ {"error": "Module with this name already exists"}+ )if members is not None:ModuleMember.objects.filter(module=instance).delete()diff --git a/web/core/components/modules/modal.tsx b/web/core/components/modules/modal.tsxindex 11df178b82..aed1b90196 100644--- a/web/core/components/modules/modal.tsx+++ b/web/core/components/modules/modal.tsx@@ -71,7 +71,7 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {setToast({type: TOAST_TYPE.ERROR,title: "Error!",- message: err?.detail ?? "Module could not be created. Please try again.",+ message: err?.detail ?? err?.error ?? "Module could not be created. Please try again.",});captureModuleEvent({eventName: MODULE_CREATED,@@ -102,7 +102,7 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {setToast({type: TOAST_TYPE.ERROR,title: "Error!",- message: err?.detail ?? "Module could not be updated. Please try again.",+ message: err?.detail ?? err?.error ?? "Module could not be updated. Please try again.",});captureModuleEvent({eventName: MODULE_UPDATED,