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:
18
apps/participation/migrations/0003_tournament_remote.py
Normal file
18
apps/participation/migrations/0003_tournament_remote.py
Normal 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'),
|
||||
),
|
||||
]
|
@ -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,
|
||||
|
@ -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">
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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,)))
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user