1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 17:42:23 +00:00

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,
})
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>"
"<p>You have currently sent <strong>{nb_solutions}</strong> solutions. "
"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>")
url = reverse_lazy("participation:participation_detail", args=(self.pk,))
content = format_lazy(text, tournament=self.tournament.name, date=localtime(self.tournament.solution_limit),
nb_solutions=self.solutions.count(), min_solutions=len(settings.PROBLEMS) - 3,
content = format_lazy(text, tournament=tournament.name, date=localtime(tournament.solution_limit),
nb_solutions=self.solutions.filter(final_solution=False).count(),
min_solutions=len(settings.PROBLEMS) - 3,
url=url)
informations.append({
'title': _("Solutions due"),
@ -733,19 +744,33 @@ class Participation(models.Model):
'priority': 1,
'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 "
"{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>")
url = reverse_lazy("draw:index")
content = format_lazy(text, tournament=self.tournament.name,
date=localtime(self.tournament.solutions_draw), url=url)
content = format_lazy(text, tournament=tournament.name,
date=localtime(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=2):
elif timezone.now() <= tournament.syntheses_first_phase_limit + timedelta(hours=2):
pool = self.pools.get(round=1, tournament=self.tournament)
defender_passage = pool.passages.get(defender=self)
opponent_passage = pool.passages.get(opponent=self)
@ -790,8 +815,8 @@ class Participation(models.Model):
'priority': 1,
'content': content,
})
elif timezone.now() <= self.tournament.syntheses_second_phase_limit + timedelta(hours=2):
pool = self.pools.get(round=2, tournament=self.tournament)
elif timezone.now() <= tournament.syntheses_second_phase_limit + timedelta(hours=2):
pool = self.pools.get(round=2, tournament=tournament)
defender_passage = pool.passages.get(defender=self)
opponent_passage = pool.passages.get(opponent=self)
reporter_passage = pool.passages.get(reporter=self)
@ -833,11 +858,11 @@ class Participation(models.Model):
'priority': 1,
'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 "
"<a href='{url}'>tournament page</a>.</p>")
url = reverse_lazy("participation:tournament_detail", args=(self.tournament.pk,))
content = format_lazy(text, tournament=self.tournament.name, url=url)
url = reverse_lazy("participation:tournament_detail", args=(tournament.pk,))
content = format_lazy(text, tournament=tournament.name, url=url)
informations.append({
'title': _("Tournament ended"),
'type': "info",

View File

@ -272,6 +272,19 @@ class ParticipantRegistration(Registration):
'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())
return informations
@ -419,6 +432,20 @@ class StudentRegistration(ParticipantRegistration):
'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
class Meta:

View File

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