Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-3285] fix: creating and updating duplicate quick links (#6557)

Sangeethaa00bb35e548c
diff --git a/apiserver/plane/app/serializers/workspace.py b/apiserver/plane/app/serializers/workspace.py
index 3467fff996..485a127aa7 100644
--- a/apiserver/plane/app/serializers/workspace.py
+++ b/apiserver/plane/app/serializers/workspace.py
@@ -147,6 +147,41 @@ class WorkspaceUserLinkSerializer(BaseSerializer):
return value
+ def create(self, validated_data):
+ # Filtering the WorkspaceUserLink with the given url to check if the link already exists.
+
+ url = validated_data.get("url")
+
+ workspace_user_link = WorkspaceUserLink.objects.filter(
+ url=url,
+ workspace_id=validated_data.get("workspace_id"),
+ owner=validated_data.get("owner")
+ )
+
+ if workspace_user_link.exists():
+ raise serializers.ValidationError(
+ {"error": "URL already exists for this workspace and owner"}
+ )
+ return WorkspaceUserLink.objects.create(**validated_data)
+
+ def update(self, instance, validated_data):
+ # Filtering the WorkspaceUserLink with the given url to check if the link already exists.
+
+ url = validated_data.get("url")
+
+ workspace_user_link = WorkspaceUserLink.objects.filter(
+ url=url,
+ workspace_id=instance.workspace_id,
+ owner=instance.owner
+ )
+
+ if workspace_user_link.exclude(pk=instance.id).exists():
+ raise serializers.ValidationError(
+ {"error": "URL already exists for this workspace and owner"}
+ )
+
+ return super().update(instance, validated_data)
+
class IssueRecentVisitSerializer(serializers.ModelSerializer):
project_identifier = serializers.SerializerMethodField()