1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-03 22:42:53 +02:00

Comment code, fix minor issues

This commit is contained in:
Yohann D'ANELLO
2020-05-11 14:08:19 +02:00
parent c9b9d01523
commit a561364bd0
22 changed files with 650 additions and 179 deletions

View File

@ -12,6 +12,11 @@ from tournament.models import Tournament, Team, Pool
class TournamentForm(forms.ModelForm):
"""
Create and update tournaments.
"""
# Only organizers can organize tournaments. Well, that's pretty normal...
organizers = forms.ModelMultipleChoiceField(
TFJMUser.objects.filter(Q(role="0admin") | Q(role="1volunteer")).order_by('role'),
label=_("Organizers"),
@ -44,6 +49,10 @@ class TournamentForm(forms.ModelForm):
class OrganizerForm(forms.ModelForm):
"""
Register an organizer in the website.
"""
class Meta:
model = TFJMUser
fields = ('last_name', 'first_name', 'email', 'is_superuser',)
@ -64,6 +73,9 @@ class OrganizerForm(forms.ModelForm):
class TeamForm(forms.ModelForm):
"""
Add and update a team.
"""
tournament = forms.ModelChoiceField(
Tournament.objects.filter(date_inscription__gte=timezone.now(), final=False),
)
@ -94,6 +106,10 @@ class TeamForm(forms.ModelForm):
class JoinTeam(forms.Form):
"""
Form to join a team with an access code.
"""
access_code = forms.CharField(
label=_("Access code"),
max_length=6,
@ -117,6 +133,10 @@ class JoinTeam(forms.Form):
class SolutionForm(forms.ModelForm):
"""
Form to upload a solution.
"""
problem = forms.ChoiceField(
label=_("Problem"),
choices=[(str(i), _("Problem #{problem:d}").format(problem=i)) for i in range(1, 9)],
@ -128,12 +148,21 @@ class SolutionForm(forms.ModelForm):
class SynthesisForm(forms.ModelForm):
"""
Form to upload a synthesis.
"""
class Meta:
model = Synthesis
fields = ('file', 'source', 'round',)
class PoolForm(forms.ModelForm):
"""
Form to add a pool.
Should not be used: prefer to pass by API and auto-add pools with the results of the draw.
"""
team1 = forms.ModelChoiceField(
Team.objects.filter(validation_status="2valid").all(),
empty_label=_("Choose a team..."),