Add api endpoints for tweaks and payments
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
81c2df7f10
commit
0ebee1910b
|
@ -61,3 +61,9 @@ class TournamentSerializer(serializers.ModelSerializer):
|
||||||
'inscription_limit', 'solution_limit', 'solutions_draw', 'syntheses_first_phase_limit',
|
'inscription_limit', 'solution_limit', 'solutions_draw', 'syntheses_first_phase_limit',
|
||||||
'solutions_available_second_phase', 'syntheses_second_phase_limit',
|
'solutions_available_second_phase', 'syntheses_second_phase_limit',
|
||||||
'description', 'organizers', 'final', 'participations',)
|
'description', 'organizers', 'final', 'participations',)
|
||||||
|
|
||||||
|
|
||||||
|
class TweakSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Team
|
||||||
|
fields = '__all__'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from .views import NoteViewSet, ParticipationViewSet, PassageViewSet, PoolViewSet, \
|
from .views import NoteViewSet, ParticipationViewSet, PassageViewSet, PoolViewSet, \
|
||||||
SolutionViewSet, SynthesisViewSet, TeamViewSet, TournamentViewSet
|
SolutionViewSet, SynthesisViewSet, TeamViewSet, TournamentViewSet, TweakViewSet
|
||||||
|
|
||||||
|
|
||||||
def register_participation_urls(router, path):
|
def register_participation_urls(router, path):
|
||||||
|
@ -17,3 +17,4 @@ def register_participation_urls(router, path):
|
||||||
router.register(path + "/synthesis", SynthesisViewSet)
|
router.register(path + "/synthesis", SynthesisViewSet)
|
||||||
router.register(path + "/team", TeamViewSet)
|
router.register(path + "/team", TeamViewSet)
|
||||||
router.register(path + "/tournament", TournamentViewSet)
|
router.register(path + "/tournament", TournamentViewSet)
|
||||||
|
router.register(path + "/tweak", TweakViewSet)
|
||||||
|
|
|
@ -4,8 +4,8 @@ from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
from .serializers import NoteSerializer, ParticipationSerializer, PassageSerializer, PoolSerializer, \
|
from .serializers import NoteSerializer, ParticipationSerializer, PassageSerializer, PoolSerializer, \
|
||||||
SolutionSerializer, SynthesisSerializer, TeamSerializer, TournamentSerializer
|
SolutionSerializer, SynthesisSerializer, TeamSerializer, TournamentSerializer, TweakSerializer
|
||||||
from ..models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament
|
from ..models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament, Tweak
|
||||||
|
|
||||||
|
|
||||||
class NoteViewSet(ModelViewSet):
|
class NoteViewSet(ModelViewSet):
|
||||||
|
@ -67,3 +67,11 @@ class TournamentViewSet(ModelViewSet):
|
||||||
'inscription_limit', 'solution_limit', 'solutions_draw', 'syntheses_first_phase_limit',
|
'inscription_limit', 'solution_limit', 'solutions_draw', 'syntheses_first_phase_limit',
|
||||||
'solutions_available_second_phase', 'syntheses_second_phase_limit',
|
'solutions_available_second_phase', 'syntheses_second_phase_limit',
|
||||||
'description', 'organizers', 'final', ]
|
'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', ]
|
||||||
|
|
|
@ -5,7 +5,7 @@ from rest_framework import serializers
|
||||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||||
|
|
||||||
from ..models import CoachRegistration, ParticipantRegistration, \
|
from ..models import CoachRegistration, ParticipantRegistration, \
|
||||||
StudentRegistration, VolunteerRegistration
|
Payment, StudentRegistration, VolunteerRegistration
|
||||||
|
|
||||||
|
|
||||||
class CoachSerializer(serializers.ModelSerializer):
|
class CoachSerializer(serializers.ModelSerializer):
|
||||||
|
@ -38,3 +38,9 @@ class RegistrationSerializer(PolymorphicSerializer):
|
||||||
StudentRegistration: StudentSerializer,
|
StudentRegistration: StudentSerializer,
|
||||||
VolunteerRegistration: VolunteerSerializer,
|
VolunteerRegistration: VolunteerSerializer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Payment
|
||||||
|
fields = '__all__'
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# Copyright (C) 2020 by Animath
|
# Copyright (C) 2020 by Animath
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from .views import RegistrationViewSet
|
from .views import PaymentViewSet, RegistrationViewSet
|
||||||
|
|
||||||
|
|
||||||
def register_registration_urls(router, path):
|
def register_registration_urls(router, path):
|
||||||
"""
|
"""
|
||||||
Configure router for registration REST API.
|
Configure router for registration REST API.
|
||||||
"""
|
"""
|
||||||
|
router.register(path + "/payment", PaymentViewSet)
|
||||||
router.register(path + "/registration", RegistrationViewSet)
|
router.register(path + "/registration", RegistrationViewSet)
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
from .serializers import RegistrationSerializer
|
from .serializers import PaymentSerializer, RegistrationSerializer
|
||||||
from ..models import Registration
|
from ..models import Payment, Registration
|
||||||
|
|
||||||
|
|
||||||
class RegistrationViewSet(ModelViewSet):
|
class RegistrationViewSet(ModelViewSet):
|
||||||
|
@ -13,3 +13,10 @@ class RegistrationViewSet(ModelViewSet):
|
||||||
serializer_class = RegistrationSerializer
|
serializer_class = RegistrationSerializer
|
||||||
filter_backends = [DjangoFilterBackend]
|
filter_backends = [DjangoFilterBackend]
|
||||||
filterset_fields = ['user', 'participantregistration__team', ]
|
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', ]
|
||||||
|
|
Loading…
Reference in New Issue