feat: already exisiting url validation (#368)

This commit is contained in:
pablohashescobar 2023-03-06 18:58:10 +05:30 committed by GitHub
parent 39f54d8265
commit 79d7b6fec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):