chore: cycle update errors (#2070)

This commit is contained in:
Nikhil 2023-09-04 14:37:29 +05:30 committed by GitHub
parent f583789584
commit dc26e1ea50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -333,13 +333,21 @@ class CycleViewSet(BaseViewSet):
workspace__slug=slug, project_id=project_id, pk=pk workspace__slug=slug, project_id=project_id, pk=pk
) )
request_data = request.data
if cycle.end_date is not None and cycle.end_date < timezone.now().date(): if cycle.end_date is not None and cycle.end_date < timezone.now().date():
return Response( if "sort_order" in request_data:
{ # Can only change sort order
"error": "The Cycle has already been completed so it cannot be edited" request_data = {
}, "sort_order": request_data.get("sort_order", cycle.sort_order)
status=status.HTTP_400_BAD_REQUEST, }
) else:
return Response(
{
"error": "The Cycle has already been completed so it cannot be edited"
},
status=status.HTTP_400_BAD_REQUEST,
)
serializer = CycleWriteSerializer(cycle, data=request.data, partial=True) serializer = CycleWriteSerializer(cycle, data=request.data, partial=True)
if serializer.is_valid(): if serializer.is_valid():
@ -373,7 +381,9 @@ class CycleViewSet(BaseViewSet):
.annotate(assignee_id=F("assignees__id")) .annotate(assignee_id=F("assignees__id"))
.annotate(avatar=F("assignees__avatar")) .annotate(avatar=F("assignees__avatar"))
.annotate(display_name=F("assignees__display_name")) .annotate(display_name=F("assignees__display_name"))
.values("first_name", "last_name", "assignee_id", "avatar", "display_name") .values(
"first_name", "last_name", "assignee_id", "avatar", "display_name"
)
.annotate(total_issues=Count("assignee_id")) .annotate(total_issues=Count("assignee_id"))
.annotate( .annotate(
completed_issues=Count( completed_issues=Count(
@ -709,7 +719,6 @@ class CycleDateCheckEndpoint(BaseAPIView):
class CycleFavoriteViewSet(BaseViewSet): class CycleFavoriteViewSet(BaseViewSet):
serializer_class = CycleFavoriteSerializer serializer_class = CycleFavoriteSerializer
model = CycleFavorite model = CycleFavorite