From 396e4c048cbc57402dcb3b97f1dfbdbf5df7c287 Mon Sep 17 00:00:00 2001 From: bbonf Date: Tue, 29 Oct 2024 11:52:13 +0100 Subject: [PATCH] separate appointment serializer for parent app --- lab/experiments/serializers.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lab/experiments/serializers.py b/lab/experiments/serializers.py index 0eb57624..f5bcf560 100644 --- a/lab/experiments/serializers.py +++ b/lab/experiments/serializers.py @@ -76,3 +76,34 @@ class Meta: "excluded_experiments", "defaultcriteria", ] + + +class ParentAppointmentSerializer(serializers.ModelSerializer): + class Meta: + model = Appointment + fields = [ + "id", + "experiment", + "leader", + "participant", + "location", + "start", + "end", + "comment", + "outcome", + "contact_phone", + "session_duration", + ] + + experiment = serializers.ReadOnlyField(source="experiment.name") + participant = serializers.ReadOnlyField(source="participant.name") + + location = serializers.ReadOnlyField() + leader = serializers.ReadOnlyField(source="leader.name") + + contact_phone = serializers.ReadOnlyField(source="leader.phonenumber") + + start = serializers.DateTimeField() + end = serializers.DateTimeField() + + session_duration = serializers.ReadOnlyField(source="experiment.session_duration")