1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-11-27 00:07:11 +00:00
plateforme-tfjm2/participation/api/views.py

78 lines
3.3 KiB
Python
Raw Normal View History

2021-03-29 13:41:20 +00:00
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
2021-03-29 14:06:09 +00:00
from django_filters.rest_framework import DjangoFilterBackend
2021-03-29 13:41:20 +00:00
from rest_framework.viewsets import ModelViewSet
from .serializers import NoteSerializer, ParticipationSerializer, PassageSerializer, PoolSerializer, \
SolutionSerializer, SynthesisSerializer, TeamSerializer, TournamentSerializer, TweakSerializer
from ..models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament, Tweak
2021-03-29 13:41:20 +00:00
class NoteViewSet(ModelViewSet):
queryset = Note.objects.all()
serializer_class = NoteSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['jury', 'passage', 'defender_writing', 'defender_oral', 'opponent_writing',
'opponent_oral', 'reporter_writing', 'reporter_oral', ]
2021-03-29 13:41:20 +00:00
class ParticipationViewSet(ModelViewSet):
queryset = Participation.objects.all()
serializer_class = ParticipationSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['team', 'team__name', 'team__trigram', 'tournament', 'tournament__name', 'valid', 'final', ]
2021-03-29 13:41:20 +00:00
class PassageViewSet(ModelViewSet):
queryset = Passage.objects.all()
serializer_class = PassageSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['pool', 'solution_number', 'defender', 'opponent', 'reporter', 'pool_tournament', ]
2021-03-29 13:41:20 +00:00
class PoolViewSet(ModelViewSet):
queryset = Pool.objects.all()
serializer_class = PoolSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['tournament', 'tournament__name', 'round', 'participations', 'juries', 'bbb_url', ]
2021-03-29 13:41:20 +00:00
class SolutionViewSet(ModelViewSet):
queryset = Solution.objects.all()
serializer_class = SolutionSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['participation', 'number', 'problem', 'final_solution', ]
2021-03-29 13:41:20 +00:00
class SynthesisViewSet(ModelViewSet):
queryset = Synthesis.objects.all()
serializer_class = SynthesisSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['participation', 'number', 'passage', 'type', ]
2021-03-29 13:41:20 +00:00
class TeamViewSet(ModelViewSet):
queryset = Team.objects.all()
serializer_class = TeamSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['name', 'trigram', 'access_code', 'participation__valid', 'participation__tournament',
'participation__tournament__name', 'participation__valid', 'participation__final', ]
2021-03-29 13:41:20 +00:00
class TournamentViewSet(ModelViewSet):
queryset = Tournament.objects.all()
serializer_class = TournamentSerializer
2021-03-29 14:06:09 +00:00
filter_backends = [DjangoFilterBackend]
filterset_fields = ['name', 'date_start', 'date_end', 'place', 'max_teams', 'price', 'remote',
'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', ]