forked from github/plane
chore: estimates and issue parent id fixes (#3188)
* chore: validations and bug fixes * chore: estimate point character limit validation --------- Co-authored-by: LAKHAN BAHETI <lakhanbaheti9@gmail.com>
This commit is contained in:
parent
05eb728c40
commit
78428fb564
@ -4,6 +4,7 @@ from .base import BaseSerializer
|
|||||||
from plane.db.models import Estimate, EstimatePoint
|
from plane.db.models import Estimate, EstimatePoint
|
||||||
from plane.app.serializers import WorkspaceLiteSerializer, ProjectLiteSerializer
|
from plane.app.serializers import WorkspaceLiteSerializer, ProjectLiteSerializer
|
||||||
|
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
class EstimateSerializer(BaseSerializer):
|
class EstimateSerializer(BaseSerializer):
|
||||||
workspace_detail = WorkspaceLiteSerializer(read_only=True, source="workspace")
|
workspace_detail = WorkspaceLiteSerializer(read_only=True, source="workspace")
|
||||||
@ -19,6 +20,15 @@ class EstimateSerializer(BaseSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class EstimatePointSerializer(BaseSerializer):
|
class EstimatePointSerializer(BaseSerializer):
|
||||||
|
|
||||||
|
def validate(self, data):
|
||||||
|
if not data:
|
||||||
|
raise serializers.ValidationError("Estimate points are required")
|
||||||
|
value = data.get("value")
|
||||||
|
if value and len(value) > 20:
|
||||||
|
raise serializers.ValidationError("Value can't be more than 20 characters")
|
||||||
|
return data
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = EstimatePoint
|
model = EstimatePoint
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
@ -54,10 +54,10 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
|
|
||||||
estimate_points = request.data.get("estimate_points", [])
|
estimate_points = request.data.get("estimate_points", [])
|
||||||
|
|
||||||
if not len(estimate_points) or len(estimate_points) > 8:
|
serializer = EstimatePointSerializer(data=request.data.get("estimate_points"), many=True)
|
||||||
|
if not serializer.is_valid():
|
||||||
return Response(
|
return Response(
|
||||||
{"error": "Estimate points are required"},
|
serializer.errors, status=status.HTTP_400_BAD_REQUEST
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
estimate_serializer = EstimateSerializer(data=request.data.get("estimate"))
|
estimate_serializer = EstimateSerializer(data=request.data.get("estimate"))
|
||||||
|
@ -50,7 +50,8 @@ class GlobalSearchEndpoint(BaseAPIView):
|
|||||||
q = Q()
|
q = Q()
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if field == "sequence_id":
|
if field == "sequence_id":
|
||||||
sequences = re.findall(r"\d+\.\d+|\d+", query)
|
# Match whole integers only (exclude decimal numbers)
|
||||||
|
sequences = re.findall(r"\b\d+\b", query)
|
||||||
for sequence_id in sequences:
|
for sequence_id in sequences:
|
||||||
q |= Q(**{"sequence_id": sequence_id})
|
q |= Q(**{"sequence_id": sequence_id})
|
||||||
else:
|
else:
|
||||||
|
@ -112,8 +112,8 @@ def track_parent(
|
|||||||
epoch,
|
epoch,
|
||||||
):
|
):
|
||||||
if current_instance.get("parent") != requested_data.get("parent"):
|
if current_instance.get("parent") != requested_data.get("parent"):
|
||||||
old_parent = Issue.objects.filter(pk=current_instance.get("parent")).first()
|
old_parent = Issue.objects.filter(pk=current_instance.get("parent")).first() if current_instance.get("parent") is not None else None
|
||||||
new_parent = Issue.objects.filter(pk=requested_data.get("parent")).first()
|
new_parent = Issue.objects.filter(pk=requested_data.get("parent")).first() if requested_data.get("parent") is not None else None
|
||||||
|
|
||||||
issue_activities.append(
|
issue_activities.append(
|
||||||
IssueActivity(
|
IssueActivity(
|
||||||
|
@ -129,6 +129,22 @@ export const CreateUpdateEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
formData.value1.length > 20 ||
|
||||||
|
formData.value2.length > 20 ||
|
||||||
|
formData.value3.length > 20 ||
|
||||||
|
formData.value4.length > 20 ||
|
||||||
|
formData.value5.length > 20 ||
|
||||||
|
formData.value6.length > 20
|
||||||
|
) {
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error!",
|
||||||
|
message: "Estimate point cannot have more than 20 characters.",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
checkDuplicates([
|
checkDuplicates([
|
||||||
formData.value1,
|
formData.value1,
|
||||||
@ -269,6 +285,12 @@ export const CreateUpdateEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name={`value${i + 1}` as keyof FormValues}
|
name={`value${i + 1}` as keyof FormValues}
|
||||||
|
rules={{
|
||||||
|
maxLength: {
|
||||||
|
value: 20,
|
||||||
|
message: "Estimate point must at most be of 20 characters",
|
||||||
|
},
|
||||||
|
}}
|
||||||
render={({ field: { value, onChange, ref } }) => (
|
render={({ field: { value, onChange, ref } }) => (
|
||||||
<Input
|
<Input
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
Loading…
Reference in New Issue
Block a user