diff --git a/apiserver/plane/app/serializers/cycle.py b/apiserver/plane/app/serializers/cycle.py index dce2b98b0e6..efc0f8f8b2d 100644 --- a/apiserver/plane/app/serializers/cycle.py +++ b/apiserver/plane/app/serializers/cycle.py @@ -20,7 +20,11 @@ def validate(self, data): data.get("start_date", None) is not None and data.get("end_date", None) is not None ): - project_id = self.initial_data.get("project_id") or self.instance.project_id + project_id = ( + self.initial_data.get("project_id", None) + or (self.instance and self.instance.get("project_id", None)) + or self.context.get("project_id", None) + ) is_start_date_end_date_equal = ( True if str(data.get("start_date")) == str(data.get("end_date")) diff --git a/apiserver/plane/app/views/cycle/base.py b/apiserver/plane/app/views/cycle/base.py index 5c80809d2a6..ad13d5fe9ba 100644 --- a/apiserver/plane/app/views/cycle/base.py +++ b/apiserver/plane/app/views/cycle/base.py @@ -54,11 +54,7 @@ # Module imports from .. import BaseAPIView, BaseViewSet from plane.bgtasks.webhook_task import model_activity -from plane.utils.timezone_converter import ( - convert_utc_to_project_timezone, - convert_to_utc, - user_timezone_converter, -) +from plane.utils.timezone_converter import convert_to_utc, user_timezone_converter class CycleViewSet(BaseViewSet): @@ -270,7 +266,9 @@ def create(self, request, slug, project_id): request.data.get("start_date", None) is not None and request.data.get("end_date", None) is not None ): - serializer = CycleWriteSerializer(data=request.data) + serializer = CycleWriteSerializer( + data=request.data, context={"project_id": project_id} + ) if serializer.is_valid(): serializer.save(project_id=project_id, owned_by=request.user) cycle = ( @@ -357,7 +355,9 @@ def partial_update(self, request, slug, project_id, pk): status=status.HTTP_400_BAD_REQUEST, ) - serializer = CycleWriteSerializer(cycle, data=request.data, partial=True) + serializer = CycleWriteSerializer( + cycle, data=request.data, partial=True, context={"project_id": project_id} + ) if serializer.is_valid(): serializer.save() cycle = queryset.values(