From b82b0435f3501bdedbbf5e8ad3a7ef19bdcf33ff Mon Sep 17 00:00:00 2001 From: Konrad Mohrfeldt <konrad.mohrfeldt@farbdev.org> Date: Tue, 22 Mar 2022 21:18:03 +0100 Subject: [PATCH] feat: return schedule dry-runs with a separate status code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Schedule dry-runs returned a 201 response before, because the only check for a 201 return code was, that the payload must not contain the "projected" keyword. As dry-runs don’t create any data 201 is not an appropriate status code. --- program/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/program/views.py b/program/views.py index c295262f..9b8fcbcf 100644 --- a/program/views.py +++ b/program/views.py @@ -372,6 +372,10 @@ class APIScheduleViewSet( # Otherwise try to resolve resolution = Schedule.resolve_conflicts(request.data, pk, show_pk) + if all(key in resolution for key in ["create", "update", "delete"]): + # this is a dry-run + return Response(resolution, status=status.HTTP_202_ACCEPTED) + # If resolution went well if "projected" not in resolution: return Response(resolution, status=status.HTTP_201_CREATED) -- GitLab