From 79d7b6fec37d2cdc319e4263d6b83559af3c8ef2 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 6 Mar 2023 18:58:10 +0530 Subject: [PATCH] feat: already exisiting url validation (#368) --- apiserver/plane/api/serializers/issue.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apiserver/plane/api/serializers/issue.py b/apiserver/plane/api/serializers/issue.py index e3afe75cf..e934f5cbd 100644 --- a/apiserver/plane/api/serializers/issue.py +++ b/apiserver/plane/api/serializers/issue.py @@ -417,6 +417,16 @@ class IssueLinkSerializer(BaseSerializer): "issue", ] + # Validation if url already exists + def create(self, validated_data): + if IssueLink.objects.filter( + url=validated_data.get("url"), issue_id=validated_data.get("issue_id") + ).exists(): + raise serializers.ValidationError( + {"error": "URL already exists for this Issue"} + ) + return IssueLink.objects.create(**validated_data) + # Issue Serializer with state details class IssueStateSerializer(BaseSerializer):