From d990f0038ba56e0c1bdda9238a3381240c41af8c Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:58:24 +0530 Subject: [PATCH] fix: module link create url validation (#678) --- apiserver/plane/api/serializers/module.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apiserver/plane/api/serializers/module.py b/apiserver/plane/api/serializers/module.py index 8e976d318..ea9edd82c 100644 --- a/apiserver/plane/api/serializers/module.py +++ b/apiserver/plane/api/serializers/module.py @@ -139,6 +139,16 @@ class ModuleLinkSerializer(BaseSerializer): "module", ] + # Validation if url already exists + def create(self, validated_data): + if ModuleLink.objects.filter( + url=validated_data.get("url"), module_id=validated_data.get("module_id") + ).exists(): + raise serializers.ValidationError( + {"error": "URL already exists for this Issue"} + ) + return ModuleLink.objects.create(**validated_data) + class ModuleSerializer(BaseSerializer): project_detail = ProjectSerializer(read_only=True, source="project")