From b3247ab568eeb22e773f95816aac8d26c89dd8ee Mon Sep 17 00:00:00 2001 From: Konrad Mohrfeldt <konrad.mohrfeldt@farbdev.org> Date: Thu, 17 Mar 2022 13:22:43 +0100 Subject: [PATCH] refactor: pre-fill show and timeslot data on note creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If notes are created through subroutes some of the data necessary to create a note is already available through the route data and doesn’t need to be passed as part of the request body anymore. --- program/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/program/views.py b/program/views.py index f00fcaa5..14ef2306 100644 --- a/program/views.py +++ b/program/views.py @@ -709,7 +709,8 @@ class APINoteViewSet(viewsets.ModelViewSet): return Response(status=status.HTTP_400_BAD_REQUEST) serializer = NoteSerializer( - data=request.data, context={"user_id": request.user.id} + data={"show": show_pk, "timeslot": timeslot_pk} | request.data, + context={"user_id": request.user.id}, ) if serializer.is_valid(): -- GitLab