[WEB-4544] chore: added field validations in serializer (#7460)
* chore: added field validations in serializer * chore: added enum for roles
This commit is contained in:
parent
27f74206a3
commit
63d025cbf4
3 changed files with 157 additions and 16 deletions
|
|
@ -20,6 +20,7 @@ from plane.db.models import (
|
|||
ProjectMember,
|
||||
State,
|
||||
User,
|
||||
EstimatePoint,
|
||||
)
|
||||
|
||||
from .base import BaseSerializer
|
||||
|
|
@ -112,13 +113,27 @@ class IssueSerializer(BaseSerializer):
|
|||
if (
|
||||
data.get("parent")
|
||||
and not Issue.objects.filter(
|
||||
workspace_id=self.context.get("workspace_id"), pk=data.get("parent").id
|
||||
workspace_id=self.context.get("workspace_id"),
|
||||
project_id=self.context.get("project_id"),
|
||||
pk=data.get("parent").id,
|
||||
).exists()
|
||||
):
|
||||
raise serializers.ValidationError(
|
||||
"Parent is not valid issue_id please pass a valid issue_id"
|
||||
)
|
||||
|
||||
if (
|
||||
data.get("estimate_point")
|
||||
and not EstimatePoint.objects.filter(
|
||||
workspace_id=self.context.get("workspace_id"),
|
||||
project_id=self.context.get("project_id"),
|
||||
pk=data.get("estimate_point").id,
|
||||
).exists()
|
||||
):
|
||||
raise serializers.ValidationError(
|
||||
"Estimate point is not valid please pass a valid estimate_point_id"
|
||||
)
|
||||
|
||||
return data
|
||||
|
||||
def create(self, validated_data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue