2021-03-29 16:24:58 +02:00
|
|
|
# Copyright (C) 2020 by Animath
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2024-03-23 11:47:42 +01:00
|
|
|
from django.contrib.auth.models import User
|
2021-03-29 16:24:58 +02:00
|
|
|
from rest_framework import serializers
|
|
|
|
from rest_polymorphic.serializers import PolymorphicSerializer
|
|
|
|
|
2023-02-20 00:23:18 +01:00
|
|
|
from ..models import CoachRegistration, ParticipantRegistration, \
|
2024-03-23 11:36:09 +01:00
|
|
|
Payment, StudentRegistration, VolunteerRegistration
|
2021-03-29 16:24:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class CoachSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = CoachRegistration
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|
|
|
|
class ParticipantSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = ParticipantRegistration
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|
|
|
|
class StudentSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = StudentRegistration
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|
|
|
|
class VolunteerSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = VolunteerRegistration
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|
|
|
|
class RegistrationSerializer(PolymorphicSerializer):
|
|
|
|
model_serializer_mapping = {
|
|
|
|
CoachRegistration: CoachSerializer,
|
|
|
|
StudentRegistration: StudentSerializer,
|
|
|
|
VolunteerRegistration: VolunteerSerializer,
|
|
|
|
}
|
2024-03-23 11:36:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
class PaymentSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Payment
|
|
|
|
fields = '__all__'
|
2024-03-23 11:47:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
class BasicUserSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
2024-03-23 23:04:22 +01:00
|
|
|
fields = ['id', 'first_name', 'last_name', 'email', ]
|