Display informations about the final tournament in the sidebar

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-07 12:38:41 +02:00
parent 7a004596ca
commit b4fc976197
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 285 additions and 200 deletions

File diff suppressed because it is too large Load Diff

View File

@ -718,14 +718,25 @@ class Participation(models.Model):
'content': content, 'content': content,
}) })
if timezone.now() <= self.tournament.solution_limit + timedelta(hours=2): if self.tournament:
informations.extend(self.informations_for_tournament(self.tournament))
if self.final:
informations.extend(self.informations_for_tournament(Tournament.final_tournament()))
return informations
def informations_for_tournament(self, tournament) -> list[dict]:
informations = []
if timezone.now() <= tournament.solution_limit + timedelta(hours=2):
if not tournament.final:
text = _("<p>The solutions for the tournament of {tournament} are due on the {date:%Y-%m-%d %H:%M}.</p>" text = _("<p>The solutions for the tournament of {tournament} are due on the {date:%Y-%m-%d %H:%M}.</p>"
"<p>You have currently sent <strong>{nb_solutions}</strong> solutions. " "<p>You have currently sent <strong>{nb_solutions}</strong> solutions. "
"We suggest to send at least <strong>{min_solutions}</strong> different solutions.</p>" "We suggest to send at least <strong>{min_solutions}</strong> different solutions.</p>"
"<p>You can upload your solutions on <a href='{url}'>your participation page</a>.</p>") "<p>You can upload your solutions on <a href='{url}'>your participation page</a>.</p>")
url = reverse_lazy("participation:participation_detail", args=(self.pk,)) url = reverse_lazy("participation:participation_detail", args=(self.pk,))
content = format_lazy(text, tournament=self.tournament.name, date=localtime(self.tournament.solution_limit), content = format_lazy(text, tournament=tournament.name, date=localtime(tournament.solution_limit),
nb_solutions=self.solutions.count(), min_solutions=len(settings.PROBLEMS) - 3, nb_solutions=self.solutions.filter(final_solution=False).count(),
min_solutions=len(settings.PROBLEMS) - 3,
url=url) url=url)
informations.append({ informations.append({
'title': _("Solutions due"), 'title': _("Solutions due"),
@ -733,19 +744,33 @@ class Participation(models.Model):
'priority': 1, 'priority': 1,
'content': content, 'content': content,
}) })
elif timezone.now() <= self.tournament.solutions_draw + timedelta(hours=2): else:
text = _("<p>The solutions for the tournament of {tournament} are due on the {date:%Y-%m-%d %H:%M}.</p>"
"<p>Remember that you can only fix minor changes to your solutions "
"without adding new parts.</p>"
"<p>You can upload your solutions on <a href='{url}'>your participation page</a>.</p>")
url = reverse_lazy("participation:participation_detail", args=(self.pk,))
content = format_lazy(text, tournament=tournament.name, date=localtime(tournament.solution_limit),
url=url)
informations.append({
'title': _("Solutions due"),
'type': "info",
'priority': 1,
'content': content,
})
elif timezone.now() <= tournament.solutions_draw + timedelta(hours=2):
text = _("<p>The draw of the solutions for the tournament {tournament} is planned on the " text = _("<p>The draw of the solutions for the tournament {tournament} is planned on the "
"{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>") "{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>")
url = reverse_lazy("draw:index") url = reverse_lazy("draw:index")
content = format_lazy(text, tournament=self.tournament.name, content = format_lazy(text, tournament=tournament.name,
date=localtime(self.tournament.solutions_draw), url=url) date=localtime(tournament.solutions_draw), url=url)
informations.append({ informations.append({
'title': _("Draw of solutions"), 'title': _("Draw of solutions"),
'type': "info", 'type': "info",
'priority': 1, 'priority': 1,
'content': content, 'content': content,
}) })
elif timezone.now() <= self.tournament.syntheses_first_phase_limit + timedelta(hours=2): elif timezone.now() <= tournament.syntheses_first_phase_limit + timedelta(hours=2):
pool = self.pools.get(round=1, tournament=self.tournament) pool = self.pools.get(round=1, tournament=self.tournament)
defender_passage = pool.passages.get(defender=self) defender_passage = pool.passages.get(defender=self)
opponent_passage = pool.passages.get(opponent=self) opponent_passage = pool.passages.get(opponent=self)
@ -790,8 +815,8 @@ class Participation(models.Model):
'priority': 1, 'priority': 1,
'content': content, 'content': content,
}) })
elif timezone.now() <= self.tournament.syntheses_second_phase_limit + timedelta(hours=2): elif timezone.now() <= tournament.syntheses_second_phase_limit + timedelta(hours=2):
pool = self.pools.get(round=2, tournament=self.tournament) pool = self.pools.get(round=2, tournament=tournament)
defender_passage = pool.passages.get(defender=self) defender_passage = pool.passages.get(defender=self)
opponent_passage = pool.passages.get(opponent=self) opponent_passage = pool.passages.get(opponent=self)
reporter_passage = pool.passages.get(reporter=self) reporter_passage = pool.passages.get(reporter=self)
@ -833,11 +858,11 @@ class Participation(models.Model):
'priority': 1, 'priority': 1,
'content': content, 'content': content,
}) })
elif not self.final: elif not self.final or tournament.final:
text = _("<p>The tournament {tournament} is ended. You can check the results on the " text = _("<p>The tournament {tournament} is ended. You can check the results on the "
"<a href='{url}'>tournament page</a>.</p>") "<a href='{url}'>tournament page</a>.</p>")
url = reverse_lazy("participation:tournament_detail", args=(self.tournament.pk,)) url = reverse_lazy("participation:tournament_detail", args=(tournament.pk,))
content = format_lazy(text, tournament=self.tournament.name, url=url) content = format_lazy(text, tournament=tournament.name, url=url)
informations.append({ informations.append({
'title': _("Tournament ended"), 'title': _("Tournament ended"),
'type': "info", 'type': "info",

View File

@ -272,6 +272,19 @@ class ParticipantRegistration(Registration):
'content': content, 'content': content,
}) })
if self.team.participation.final:
if not self.photo_authorization_final:
text = _("You have not uploaded your photo authorization for the final tournament. "
"You can do it by clicking on <a href=\"{photo_url}\">this link</a>.")
photo_url = reverse_lazy("registration:upload_user_photo_authorization_final", args=(self.id,))
content = format_lazy(text, photo_url=photo_url)
informations.append({
'title': _("Photo authorization"),
'type': "danger",
'priority': 5,
'content': content,
})
informations.extend(self.team.important_informations()) informations.extend(self.team.important_informations())
return informations return informations
@ -419,6 +432,20 @@ class StudentRegistration(ParticipantRegistration):
'content': content, 'content': content,
}) })
if self.team.participation.final:
if self.under_18_final and not self.parental_authorization_final:
text = _("You have not uploaded your parental authorization for the final tournament. "
"You can do it by clicking on <a href=\"{parental_url}\">this link</a>.")
parental_url = reverse_lazy("registration:upload_user_parental_authorization_final",
args=(self.id,))
content = format_lazy(text, parental_url=parental_url)
informations.append({
'title': _("Parental authorization"),
'type': "danger",
'priority': 5,
'content': content,
})
return informations return informations
class Meta: class Meta:

View File

@ -31,8 +31,8 @@ from tfjm.tokens import email_validation_token
from tfjm.views import UserMixin, UserRegistrationMixin, VolunteerMixin from tfjm.views import UserMixin, UserRegistrationMixin, VolunteerMixin
from .forms import AddOrganizerForm, CoachRegistrationForm, HealthSheetForm, \ from .forms import AddOrganizerForm, CoachRegistrationForm, HealthSheetForm, \
PhotoAuthorizationFinalForm, ParentalAuthorizationForm, PaymentAdminForm, PaymentForm, \ ParentalAuthorizationFinalForm, ParentalAuthorizationForm, PaymentAdminForm, PaymentForm, \
ParentalAuthorizationFinalForm, PhotoAuthorizationForm, SignupForm, StudentRegistrationForm, UserForm, \ PhotoAuthorizationFinalForm, PhotoAuthorizationForm, SignupForm, StudentRegistrationForm, UserForm, \
VaccineSheetForm, VolunteerRegistrationForm VaccineSheetForm, VolunteerRegistrationForm
from .models import ParticipantRegistration, Payment, Registration, StudentRegistration from .models import ParticipantRegistration, Payment, Registration, StudentRegistration
from .tables import RegistrationTable from .tables import RegistrationTable