diff --git a/participation/api/serializers.py b/participation/api/serializers.py index 683826f..5aa2b27 100644 --- a/participation/api/serializers.py +++ b/participation/api/serializers.py @@ -61,3 +61,9 @@ class TournamentSerializer(serializers.ModelSerializer): 'inscription_limit', 'solution_limit', 'solutions_draw', 'syntheses_first_phase_limit', 'solutions_available_second_phase', 'syntheses_second_phase_limit', 'description', 'organizers', 'final', 'participations',) + + +class TweakSerializer(serializers.ModelSerializer): + class Meta: + model = Team + fields = '__all__' diff --git a/participation/api/urls.py b/participation/api/urls.py index fd27494..7034d0c 100644 --- a/participation/api/urls.py +++ b/participation/api/urls.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from .views import NoteViewSet, ParticipationViewSet, PassageViewSet, PoolViewSet, \ - SolutionViewSet, SynthesisViewSet, TeamViewSet, TournamentViewSet + SolutionViewSet, SynthesisViewSet, TeamViewSet, TournamentViewSet, TweakViewSet def register_participation_urls(router, path): @@ -17,3 +17,4 @@ def register_participation_urls(router, path): router.register(path + "/synthesis", SynthesisViewSet) router.register(path + "/team", TeamViewSet) router.register(path + "/tournament", TournamentViewSet) + router.register(path + "/tweak", TweakViewSet) diff --git a/participation/api/views.py b/participation/api/views.py index a1a159b..aa6793a 100644 --- a/participation/api/views.py +++ b/participation/api/views.py @@ -4,8 +4,8 @@ from django_filters.rest_framework import DjangoFilterBackend from rest_framework.viewsets import ModelViewSet from .serializers import NoteSerializer, ParticipationSerializer, PassageSerializer, PoolSerializer, \ - SolutionSerializer, SynthesisSerializer, TeamSerializer, TournamentSerializer -from ..models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament + SolutionSerializer, SynthesisSerializer, TeamSerializer, TournamentSerializer, TweakSerializer +from ..models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament, Tweak class NoteViewSet(ModelViewSet): @@ -67,3 +67,11 @@ class TournamentViewSet(ModelViewSet): 'inscription_limit', 'solution_limit', 'solutions_draw', 'syntheses_first_phase_limit', 'solutions_available_second_phase', 'syntheses_second_phase_limit', 'description', 'organizers', 'final', ] + + +class TweakViewSet(ModelViewSet): + queryset = Tweak.objects.all() + serializer_class = TweakSerializer + filter_backends = [DjangoFilterBackend] + filterset_fields = ['pool', 'pool__tournament', 'pool__tournament__name', 'participation', + 'participation__team__trigram', 'diff', ] diff --git a/registration/api/serializers.py b/registration/api/serializers.py index 0c00600..14330b1 100644 --- a/registration/api/serializers.py +++ b/registration/api/serializers.py @@ -5,7 +5,7 @@ from rest_framework import serializers from rest_polymorphic.serializers import PolymorphicSerializer from ..models import CoachRegistration, ParticipantRegistration, \ - StudentRegistration, VolunteerRegistration + Payment, StudentRegistration, VolunteerRegistration class CoachSerializer(serializers.ModelSerializer): @@ -38,3 +38,9 @@ class RegistrationSerializer(PolymorphicSerializer): StudentRegistration: StudentSerializer, VolunteerRegistration: VolunteerSerializer, } + + +class PaymentSerializer(serializers.ModelSerializer): + class Meta: + model = Payment + fields = '__all__' diff --git a/registration/api/urls.py b/registration/api/urls.py index 620d6ac..b7bce3d 100644 --- a/registration/api/urls.py +++ b/registration/api/urls.py @@ -1,11 +1,12 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later -from .views import RegistrationViewSet +from .views import PaymentViewSet, RegistrationViewSet def register_registration_urls(router, path): """ Configure router for registration REST API. """ + router.register(path + "/payment", PaymentViewSet) router.register(path + "/registration", RegistrationViewSet) diff --git a/registration/api/views.py b/registration/api/views.py index 7e48cfe..dc787e9 100644 --- a/registration/api/views.py +++ b/registration/api/views.py @@ -4,8 +4,8 @@ from django_filters.rest_framework import DjangoFilterBackend from rest_framework.viewsets import ModelViewSet -from .serializers import RegistrationSerializer -from ..models import Registration +from .serializers import PaymentSerializer, RegistrationSerializer +from ..models import Payment, Registration class RegistrationViewSet(ModelViewSet): @@ -13,3 +13,10 @@ class RegistrationViewSet(ModelViewSet): serializer_class = RegistrationSerializer filter_backends = [DjangoFilterBackend] filterset_fields = ['user', 'participantregistration__team', ] + + +class PaymentViewSet(ModelViewSet): + queryset = Payment.objects.all() + serializer_class = PaymentSerializer + filter_backends = [DjangoFilterBackend] + filterset_fields = ['registrations', 'grouped', 'amount', 'final', 'type', 'valid', ]