1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 12:38:26 +02:00

Don't request too many authorizations for remote tournaments

This commit is contained in:
Yohann D'ANELLO
2021-01-23 19:57:25 +01:00
parent 4dd3c105fe
commit 2bd6988c6a
8 changed files with 223 additions and 182 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.11 on 2021-01-23 18:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('participation', '0002_auto_20210122_1926'),
]
operations = [
migrations.AddField(
model_name='tournament',
name='remote',
field=models.BooleanField(default=False, verbose_name='remote'),
),
]

View File

@ -157,6 +157,11 @@ class Tournament(models.Model):
default=21,
)
remote = models.BooleanField(
verbose_name=_("remote"),
default=False,
)
inscription_limit = models.DateTimeField(
verbose_name=_("limit date for registrations"),
default=timezone.now,

View File

@ -60,31 +60,33 @@
{% endfor %}
</dd>
<dt class="col-sm-6 text-right">{% trans "Health sheets:" %}</dt>
<dd class="col-sm-6">
{% for student in team.students.all %}
{% if student.under_18 %}
{% if student.health_sheet %}
<a href="{{ student.health_sheet.url }}" data-turbolinks="false">{{ student }}</a>{% if not forloop.last %},{% endif %}
{% else %}
{{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
{% if not team.participation.tournament.remote %}
<dt class="col-sm-6 text-right">{% trans "Health sheets:" %}</dt>
<dd class="col-sm-6">
{% for student in team.students.all %}
{% if student.under_18 %}
{% if student.health_sheet %}
<a href="{{ student.health_sheet.url }}" data-turbolinks="false">{{ student }}</a>{% if not forloop.last %},{% endif %}
{% else %}
{{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</dd>
{% endfor %}
</dd>
<dt class="col-sm-6 text-right">{% trans "Parental authorizations:" %}</dt>
<dd class="col-sm-6">
{% for student in team.students.all %}
{% if student.under_18 %}
{% if student.parental_authorization %}
<a href="{{ student.parental_authorization.url }}" data-turbolinks="false">{{ student }}</a>{% if not forloop.last %},{% endif %}
{% else %}
{{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
<dt class="col-sm-6 text-right">{% trans "Parental authorizations:" %}</dt>
<dd class="col-sm-6">
{% for student in team.students.all %}
{% if student.under_18 %}
{% if student.parental_authorization %}
<a href="{{ student.parental_authorization.url }}" data-turbolinks="false">{{ student }}</a>{% if not forloop.last %},{% endif %}
{% else %}
{{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</dd>
{% endfor %}
</dd>
{% endif %}
<dt class="col-sm-6 text-right">{% trans "Motivation letter:" %}</dt>
<dd class="col-sm-6">

View File

@ -21,6 +21,9 @@
<dt class="col-xl-6 text-right">{% trans 'price'|capfirst %}</dt>
<dd class="col-xl-6">{% if tournament.price %}{{ tournament.price }} €{% else %}{% trans "Free" %}{% endif %}</dd>
<dt class="col-xl-6 text-right">{% trans 'remote'|capfirst %}</dt>
<dd class="col-xl-6">{{ tournament.remote|yesno }}</dd>
<dt class="col-xl-6 text-right">{% trans 'dates'|capfirst %}</dt>
<dd class="col-xl-6">{% trans "From" %} {{ tournament.date_start }} {% trans "to" %} {{ tournament.date_end }}</dd>

View File

@ -292,6 +292,8 @@ class TestStudentParticipation(TestCase):
self.assertEqual(resp.status_code, 200)
self.assertFalse(resp.context["can_validate"])
self.team.participation.tournament = self.tournament
self.team.participation.save()
self.team.motivation_letter = "i_am_motivated.pdf"
self.team.save()
resp = self.client.get(reverse("participation:team_detail", args=(self.team.pk,)))

View File

@ -177,10 +177,13 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
# A team is complete when there are at least 4 members plus a coache that have sent their authorizations,
# their health sheet, they confirmed their email address and under-18 people sent their parental authorization.
context["can_validate"] = team.students.count() >= 4 and team.coaches.exists() and \
team.participation.tournament and \
all(r.email_confirmed for r in team.students.all()) and \
all(r.photo_authorization for r in team.participants.all()) and \
all(r.health_sheet for r in team.students.all() if r.under_18) and \
all(r.parental_authorization for r in team.students.all() if r.under_18) and \
(team.participation.tournament.remote
or all(r.health_sheet for r in team.students.all() if r.under_18)) and \
(team.participation.tournament.remote
or all(r.parental_authorization for r in team.students.all() if r.under_18)) and \
team.motivation_letter
return context