mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-02-23 13:41:18 +00:00
Compare commits
2 Commits
a45d57e51a
...
1df1766753
Author | SHA1 | Date | |
---|---|---|---|
1df1766753 | |||
9359aa7606 |
@ -1,4 +1,4 @@
|
||||
FROM python:3.8-alpine
|
||||
FROM python:3.9-alpine
|
||||
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
ENV DJANGO_ALLOW_ASYNC_UNSAFE 1
|
||||
|
@ -16,6 +16,10 @@ if "logs" in settings.INSTALLED_APPS:
|
||||
from logs.api.urls import register_logs_urls
|
||||
register_logs_urls(router, "logs")
|
||||
|
||||
if "participation" in settings.INSTALLED_APPS:
|
||||
from participation.api.urls import register_participation_urls
|
||||
register_participation_urls(router, "participation")
|
||||
|
||||
app_name = 'api'
|
||||
|
||||
# Wire up our API using automatic URL routing.
|
||||
|
2
apps/participation/api/__init__.py
Normal file
2
apps/participation/api/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
61
apps/participation/api/serializers.py
Normal file
61
apps/participation/api/serializers.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Copyright (C) 2020 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from ..models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament
|
||||
|
||||
|
||||
class NoteSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Note
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ParticipationSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Participation
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class PassageSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Passage
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class PoolSerializer(serializers.ModelSerializer):
|
||||
passages = serializers.ListSerializer(child=PassageSerializer())
|
||||
|
||||
class Meta:
|
||||
model = Pool
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class SolutionSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Solution
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class SynthesisSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Synthesis
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class TeamSerializer(serializers.ModelSerializer):
|
||||
participation = ParticipationSerializer()
|
||||
|
||||
class Meta:
|
||||
model = Team
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class TournamentSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Tournament
|
||||
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', 'participations',)
|
19
apps/participation/api/urls.py
Normal file
19
apps/participation/api/urls.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (C) 2020 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from .views import NoteViewSet, ParticipationViewSet, PassageViewSet, PoolViewSet, \
|
||||
SolutionViewSet, SynthesisViewSet, TeamViewSet, TournamentViewSet
|
||||
|
||||
|
||||
def register_participation_urls(router, path):
|
||||
"""
|
||||
Configure router for participation REST API.
|
||||
"""
|
||||
router.register(path + "/note", NoteViewSet)
|
||||
router.register(path + "/participation", ParticipationViewSet)
|
||||
router.register(path + "/passage", PassageViewSet)
|
||||
router.register(path + "/pool", PoolViewSet)
|
||||
router.register(path + "/solution", SolutionViewSet)
|
||||
router.register(path + "/synthesis", SynthesisViewSet)
|
||||
router.register(path + "/team", TeamViewSet)
|
||||
router.register(path + "/tournament", TournamentViewSet)
|
69
apps/participation/api/views.py
Normal file
69
apps/participation/api/views.py
Normal file
@ -0,0 +1,69 @@
|
||||
# Copyright (C) 2020 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
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
|
||||
|
||||
|
||||
class NoteViewSet(ModelViewSet):
|
||||
queryset = Note.objects.all()
|
||||
serializer_class = NoteSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['jury', 'passage', 'defender_writing', 'defender_oral', 'opponent_writing',
|
||||
'opponent_oral', 'reporter_writing', 'reporter_oral', ]
|
||||
|
||||
|
||||
class ParticipationViewSet(ModelViewSet):
|
||||
queryset = Participation.objects.all()
|
||||
serializer_class = ParticipationSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['team', 'team__name', 'team__trigram', 'tournament', 'tournament__name', 'valid', 'final', ]
|
||||
|
||||
|
||||
class PassageViewSet(ModelViewSet):
|
||||
queryset = Passage.objects.all()
|
||||
serializer_class = PassageSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['pool', 'place', 'solution_number', 'defender', 'opponent', 'reporter', ]
|
||||
|
||||
|
||||
class PoolViewSet(ModelViewSet):
|
||||
queryset = Pool.objects.all()
|
||||
serializer_class = PoolSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['tournament', 'tournament__name', 'round', 'participations', 'juries', 'bbb_url', ]
|
||||
|
||||
|
||||
class SolutionViewSet(ModelViewSet):
|
||||
queryset = Solution.objects.all()
|
||||
serializer_class = SolutionSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['participation', 'number', 'problem', 'final_solution', ]
|
||||
|
||||
|
||||
class SynthesisViewSet(ModelViewSet):
|
||||
queryset = Synthesis.objects.all()
|
||||
serializer_class = SynthesisSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['participation', 'number', 'passage', 'type', ]
|
||||
|
||||
|
||||
class TeamViewSet(ModelViewSet):
|
||||
queryset = Team.objects.all()
|
||||
serializer_class = TeamSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['name', 'trigram', 'access_code', 'participation__valid', 'participation__tournament',
|
||||
'participation__tournament__name', 'participation__valid', 'participation__final', ]
|
||||
|
||||
|
||||
class TournamentViewSet(ModelViewSet):
|
||||
queryset = Tournament.objects.all()
|
||||
serializer_class = TournamentSerializer
|
||||
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', ]
|
@ -1,5 +1,5 @@
|
||||
asgiref~=3.3.1
|
||||
Django~=3.0
|
||||
Django~=3.1
|
||||
django-address~=0.2
|
||||
django-bootstrap-datepicker-plus~=3.0
|
||||
django-cas-server~=1.2
|
||||
@ -19,7 +19,7 @@ phonenumbers~=8.9.10
|
||||
psycopg2-binary~=2.8
|
||||
PyPDF3~=1.0.2
|
||||
ipython~=7.19.0
|
||||
python-magic==0.4.18
|
||||
python-magic>=0.4.21
|
||||
requests~=2.25.0
|
||||
sympasoap~=1.0
|
||||
whoosh~=2.7
|
Loading…
x
Reference in New Issue
Block a user