Automatically confirm students if they've already paid

This commit is contained in:
Tanner Collin 2022-05-12 06:16:17 +00:00
parent 0ed69e36e7
commit f9d94a4a05

View File

@ -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'])