From f9d94a4a0577c8ac57411fc0faddd01e442cbcac Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 12 May 2022 06:16:17 +0000 Subject: [PATCH] Automatically confirm students if they've already paid --- apiserver/apiserver/api/serializers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index f896cec..d74dbf7 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -457,6 +457,11 @@ class TrainingSerializer(serializers.ModelSerializer): def get_student_id(self, obj): return obj.user.member.id + def update(self, instance, validated_data): + if validated_data['attendance_status'] == 'Waiting for payment' and instance.paid_date: + validated_data['attendance_status'] = 'Confirmed' + return super().update(instance, validated_data) + class StudentTrainingSerializer(TrainingSerializer): attendance_status = serializers.ChoiceField(['Waiting for payment', 'Withdrawn'])