From 572a6c329911ee4aac5a98c821b796f20d3b0325 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 30 Mar 2024 22:23:34 +0100 Subject: [PATCH] Add information to teams and juries about pools Signed-off-by: Emmy D'Anello --- participation/models.py | 92 ++++++++++++++++++++++++++++++++++++++++- registration/models.py | 55 ++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 2 deletions(-) diff --git a/participation/models.py b/participation/models.py index 15063aa..71fd054 100644 --- a/participation/models.py +++ b/participation/models.py @@ -1,7 +1,7 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later -from datetime import date +from datetime import date, timedelta import os from django.conf import settings @@ -698,7 +698,7 @@ class Participation(models.Model): 'content': content, }) - if timezone.now() <= self.tournament.solution_limit: + if timezone.now() <= self.tournament.solution_limit + timedelta(hours=4): text = _("

The solutions for the tournament of {tournament} are due on the {date:%Y-%m-%d %H:%M}.

" "

You have currently sent {nb_solutions} solutions. " "We suggest to send at least {min_solutions} different solutions.

" @@ -713,6 +713,94 @@ class Participation(models.Model): 'priority': 1, 'content': content, }) + elif timezone.now() <= self.tournament.solutions_draw + timedelta(hours=4): + text = _("

The draw of the solutions for the tournament {tournament} is planned on the " + "{date:%Y-%m-%d %H:%M}. You can join it on this link.

") + url = reverse_lazy("draw:index") + content = format_lazy(text, tournament=self.tournament.name, date=self.tournament.solutions_draw, url=url) + informations.append({ + 'title': _("Draw of solutions"), + 'type': "info", + 'priority': 1, + 'content': content, + }) + elif timezone.now() <= self.tournament.syntheses_first_phase_limit + timedelta(hours=4): + pool = self.pools.get(round=1, tournament=self.tournament) + defender_passage = pool.passages.get(defender=self) + opponent_passage = pool.passages.get(opponent=self) + reporter_passage = pool.passages.get(reporter=self) + + defender_text = _("

The solutions draw is ended. You can check the result on " + "this page.

" + "

For the first round, you will defend " + "your solution of the problem {problem}.

") + draw_url = reverse_lazy("draw:index") + solution_url = reverse_lazy("participation:solution_detail", args=(defender_passage.defended_solution.pk,)) + defender_content = format_lazy(defender_text, draw_url=draw_url, + solution_url=solution_url, problem=defender_passage.problem) + + opponent_text = _("

You will oppose the solution of the team {opponent} on the problem {problem}. " + "You can upload your synthesis sheet on this page.

") + passage_url = reverse_lazy("participation:passage_detail", args=(opponent_passage.pk,)) + opponent_content = format_lazy(opponent_text, opponent=opponent_passage.defender.team.trigram, + problem=opponent_passage.problem, passage_url=passage_url) + + reporter_text = _("

You will report the solution of the team {reporter} on the problem {problem}. " + "You can upload your synthesis sheet on this page.

") + passage_url = reverse_lazy("participation:passage_detail", args=(reporter_passage.pk,)) + reporter_content = format_lazy(reporter_text, reporter=reporter_passage.defender.team.trigram, + problem=reporter_passage.problem, passage_url=passage_url) + + content = defender_content + opponent_content + reporter_content + informations.append({ + 'title': _("First round"), + 'type': "info", + 'priority': 1, + 'content': content, + }) + elif timezone.now() <= self.tournament.syntheses_second_phase_limit + timedelta(hours=4): + pool = self.pools.get(round=2, tournament=self.tournament) + defender_passage = pool.passages.get(defender=self) + opponent_passage = pool.passages.get(opponent=self) + reporter_passage = pool.passages.get(reporter=self) + + defender_text = _("

For the second round, you will defend " + "your solution of the problem {problem}.

") + draw_url = reverse_lazy("draw:index") + solution_url = reverse_lazy("participation:solution_detail", args=(defender_passage.defended_solution.pk,)) + defender_content = format_lazy(defender_text, draw_url=draw_url, + solution_url=solution_url, problem=defender_passage.problem) + + opponent_text = _("

You will oppose the solution of the team {opponent} on the problem {problem}. " + "You can upload your synthesis sheet on this page.

") + passage_url = reverse_lazy("participation:passage_detail", args=(opponent_passage.pk,)) + opponent_content = format_lazy(opponent_text, opponent=opponent_passage.defender.team.trigram, + problem=opponent_passage.problem, passage_url=passage_url) + + reporter_text = _("

You will report the solution of the team {reporter} on the problem {problem}. " + "You can upload your synthesis sheet on this page.

") + passage_url = reverse_lazy("participation:passage_detail", args=(reporter_passage.pk,)) + reporter_content = format_lazy(reporter_text, reporter=reporter_passage.defender.team.trigram, + problem=reporter_passage.problem, passage_url=passage_url) + + content = defender_content + opponent_content + reporter_content + informations.append({ + 'title': _("Second round"), + 'type': "info", + 'priority': 1, + 'content': content, + }) + elif not self.final: + text = _("

The tournament {tournament} is ended. You can check the results on the " + "tournament page.

") + url = reverse_lazy("participation:tournament_detail", args=(self.tournament.pk,)) + content = format_lazy(text, tournament=self.tournament.name, url=url) + informations.append({ + 'title': _("Tournament ended"), + 'type': "info", + 'priority': 1, + 'content': content, + }) return informations diff --git a/registration/models.py b/registration/models.py index 00b0603..61aa4b3 100644 --- a/registration/models.py +++ b/registration/models.py @@ -17,6 +17,8 @@ from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ from phonenumber_field.modelfields import PhoneNumberField from polymorphic.models import PolymorphicModel + +from participation.models import Note from tfjm import helloasso from tfjm.tokens import email_validation_token @@ -513,6 +515,59 @@ class VolunteerRegistration(Registration): 'content': content, }) + if timezone.now() > tournament.solution_limit and timezone.now() < tournament.solutions_draw: + text = _("

The draw of the solutions for the tournament {tournament} is planned on the " + "{date:%Y-%m-%d %H:%M}. You can join it on this link.

") + url = reverse_lazy("draw:index") + content = format_lazy(text, tournament=self.tournament.name, date=self.tournament.solutions_draw, + url=url) + informations.append({ + 'title': _("Draw of solutions"), + 'type': "info", + 'priority': 1, + 'content': content, + }) + + pools = tournament.pools.filter(juries=self).order_by('round').all() + for pool in pools: + if pool.round == 1 and timezone.now().date() <= tournament.date_start: + text = _("

You are in the jury of the pool {pool} for the tournament of {tournament}. " + "You can find the pool page here.

") + pool_url = reverse_lazy("participation:pool_detail", args=(pool.id,)) + content = format_lazy(text, pool=pool.short_name, tournament=tournament.name, pool_url=pool_url) + informations.append({ + 'title': _("First round"), + 'type': "info", + 'priority': 1, + 'content': content, + }) + elif pool.round == 2 and timezone.now().date() <= tournament.date_end: + text = _("

You are in the jury of the pool {pool} for the tournament of {tournament}. " + "You can find the pool page here.

") + pool_url = reverse_lazy("participation:pool_detail", args=(pool.id,)) + content = format_lazy(text, pool=pool.short_name, tournament=tournament.name, pool_url=pool_url) + informations.append({ + 'title': _("Second round"), + 'type': "info", + 'priority': 2, + 'content': content, + }) + + for note in Note.objects.filter(jury=self.request.user, passage__pool=pool).all(): + if not note.has_any_note(): + text = _("

You don't have given any note as a jury for the passage {passage} " + "in the pool {pool} of {tournament}. " + "You can set your notes here.

") + passage_url = reverse_lazy("participation:passage_detail", args=(note.passage.id,)) + content = format_lazy(text, passage=note.passage.position, pool=pool.short_name, + tournament=tournament.name, passage_url=passage_url) + informations.append({ + 'title': _("Note"), + 'type': "warning", + 'priority': 3 + note.passage.position, + 'content': content, + }) + return informations class Meta: