1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 09:18:23 +02:00

Add information about team registration

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-02-11 22:24:22 +01:00
parent 652e913f49
commit bc67d1cf1f
2 changed files with 273 additions and 170 deletions

View File

@ -67,6 +67,8 @@ class Team(models.Model):
return self.participants.filter(coachregistration__isnull=False)
def can_validate(self):
if any(not r.email_confirmed for r in self.participants.all()):
return False
if self.students.count() < 4:
return False
if not self.coaches.exists():
@ -91,60 +93,108 @@ class Team(models.Model):
if self.participation.valid is None:
if not self.participation.tournament:
text = _("The team is not registered to any tournament. "
text = _("The team {trigram} is not registered to any tournament. "
"You can register the team to a tournament using <a href='{url}'>this link</a>.")
url = reverse_lazy("participation:update_team", args=(self.pk,))
content = format_lazy(text, url=url)
content = format_lazy(text, trigram=self.trigram, url=url)
informations.append({
'title': _("No tournament"),
'type': "danger",
'priority': 4,
'content': content,
})
elif not self.motivation_letter:
text = _("The team has not uploaded a motivation letter. "
"You can upload your motivation letter using <a href='{url}'>this link</a>.")
url = reverse_lazy("participation:upload_team_motivation_letter", args=(self.pk,))
content = format_lazy(text, url=url)
else:
text = _("Registrations for the tournament of {tournament} are ending on the {date:%Y-%m-%d %H:%M}.")
content = format_lazy(text,
tournament=self.participation.tournament.name,
date=self.participation.tournament.inscription_limit)
informations.append({
'title': _("No motivation letter"),
'type': "danger",
'priority': 10,
'title': _("Registrations closure"),
'type': "info",
'priority': 1,
'content': content,
})
if (nb_students := self.students.count()) < 4:
text = _("The team has less than 4 students ({nb_students})."
"You can invite more students to join the team using the invite code <strong>{code}</strong>.")
content = format_lazy(text, nb_students=nb_students, code=self.access_code)
informations.append({
'title': _("Not enough students"),
'type': "warning",
'priority': 7,
'content': content,
})
if not self.motivation_letter:
text = _("The team {trigram} has not uploaded a motivation letter. "
"You can upload your motivation letter using <a href='{url}'>this link</a>.")
url = reverse_lazy("participation:upload_team_motivation_letter", args=(self.pk,))
content = format_lazy(text, trigram=self.trigram, url=url)
informations.append({
'title': _("No motivation letter"),
'type': "danger",
'priority': 10,
'content': content,
})
if not self.coaches.exists():
text = _("The team has no coach."
"You can invite a coach to join the team using the invite code <strong>{code}</strong>.")
content = format_lazy(text, nb_students=nb_students, code=self.access_code)
informations.append({
'title': _("No coach"),
'type': "warning",
'priority': 8,
'content': content,
})
nb_students = self.students.count()
nb_coaches = self.coaches.count()
if nb_students < 4:
text = _("The team {trigram} has less than 4 students ({nb_students}). "
"You can invite more students to join the team using "
"the invite code <strong>{code}</strong>.")
content = format_lazy(text, trigram=self.trigram, nb_students=nb_students, code=self.access_code)
informations.append({
'title': _("Not enough students"),
'type': "warning",
'priority': 7,
'content': content,
})
if (nb_students := self.students.count()) > 6 or self.coaches.count() > 2:
text = _("The team has more than 6 students ({nb_students}) or more than 2 coaches ({nb_coaches})."
"You have to restrict the number of students and coaches to 6 and 2, respectively.")
content = format_lazy(text, nb_students=nb_students, nb_coaches=self.coaches.count())
informations.append({
'title': _("Too many members"),
'type': "warning",
'priority': 7,
'content': content,
})
if not nb_coaches:
text = _("The team {trigram} has no coach. "
"You can invite a coach to join the team using the invite code <strong>{code}</strong>.")
content = format_lazy(text, trigram=self.trigram, nb_students=nb_students, code=self.access_code)
informations.append({
'title': _("No coach"),
'type': "warning",
'priority': 8,
'content': content,
})
if nb_students > 6 or nb_coaches > 2:
text = _("The team {trigram} has more than 6 students ({nb_students}) "
"or more than 2 coaches ({nb_coaches})."
"You have to restrict the number of students and coaches to 6 and 2, respectively.")
content = format_lazy(text, trigram=self.trigram, nb_students=nb_students, nb_coaches=nb_coaches)
informations.append({
'title': _("Too many members"),
'type': "warning",
'priority': 7,
'content': content,
})
elif nb_students >= 4 and nb_coaches >= 1:
if self.can_validate():
text = _("The team {trigram} is ready to be validated. "
"You can request validation on <a href='{url}'>the page of your team</a>.")
url = reverse_lazy("participation:team_detail", args=(self.pk,))
content = format_lazy(text, trigram=self.trigram, url=url)
informations.append({
'title': _("Validate team"),
'type': "success",
'priority': 2,
'content': content,
})
else:
text = _("The team {trigram} has enough participants, but is not ready to be validated. "
"Please make sure that all the participants have uploaded the required documents. "
"To invite more participants, use the invite code <strong>{code}</strong>.")
content = format_lazy(text, trigram=self.trigram, code=self.access_code)
informations.append({
'title': _("Validate team"),
'type': "warning",
'priority': 10,
'content': content,
})
elif self.participation.valid is False:
text = _("The team {trigram} has not been validated by the organizers yet. Please be patient.")
content = format_lazy(text, trigram=self.trigram)
informations.append({
'title': _("Pending validation"),
'type': "warning",
'priority': 2,
'content': content,
})
return informations