fix: cycle date check endpoint for updation (#1006)

* fix: cycle date check endpoint for updation

* dev: update the cycle date check endpoint to exclude current cycle when updating
This commit is contained in:
pablohashescobar 2023-05-05 15:13:22 +05:30 committed by GitHub
parent 993cf3faba
commit fd96c54b43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -414,10 +414,11 @@ class CycleDateCheckEndpoint(BaseAPIView):
try: try:
start_date = request.data.get("start_date", False) start_date = request.data.get("start_date", False)
end_date = request.data.get("end_date", False) end_date = request.data.get("end_date", False)
cycle_id = request.data.get("cycle_id", False)
if not start_date or not end_date: if not start_date or not end_date:
return Response( return Response(
{"error": "Start date and end date both are required"}, {"error": "Start date and end date are required"},
status=status.HTTP_400_BAD_REQUEST, status=status.HTTP_400_BAD_REQUEST,
) )
@ -429,6 +430,11 @@ class CycleDateCheckEndpoint(BaseAPIView):
project_id=project_id, project_id=project_id,
) )
if cycle_id:
cycles = cycles.filter(
~Q(pk=cycle_id),
)
if cycles.exists(): if cycles.exists():
return Response( return Response(
{ {