Add api endpoints for tweaks and payments

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-03-23 11:36:09 +01:00
parent 81c2df7f10
commit 0ebee1910b
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
6 changed files with 36 additions and 7 deletions

View File

@ -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__'

View File

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

View File

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

View File

@ -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__'

View File

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

View File

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