The health sheet is required only for children

This commit is contained in:
Yohann D'ANELLO 2021-01-21 21:55:19 +01:00
parent ae520f791c
commit 72fe279f15
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
8 changed files with 50 additions and 25 deletions

View File

@ -62,11 +62,13 @@
<dt class="col-sm-6 text-right">{% trans "Health sheets:" %}</dt>
<dd class="col-sm-6">
{% for participant in team.participants.all %}
{% if participant.health_sheet %}
<a href="{{ participant.health_sheet.url }}" data-turbolinks="false">{{ participant }}</a>{% if not forloop.last %},{% endif %}
{% 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 %}
{{ participant }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
{{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</dd>

View File

@ -177,7 +177,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
context["can_validate"] = team.students.count() >= 4 and team.coaches.exists() 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.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)
return context

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.11 on 2021-01-21 20:53
from django.db import migrations, models
import registration.models
class Migration(migrations.Migration):
dependencies = [
('registration', '0003_auto_20210118_1738'),
]
operations = [
migrations.RemoveField(
model_name='participantregistration',
name='health_sheet',
),
migrations.AddField(
model_name='studentregistration',
name='health_sheet',
field=models.FileField(blank=True, default='', upload_to=registration.models.get_random_health_filename, verbose_name='health sheet'),
),
]

View File

@ -146,13 +146,6 @@ class ParticipantRegistration(Registration):
default="",
)
health_sheet = models.FileField(
verbose_name=_("health sheet"),
upload_to=get_random_health_filename,
blank=True,
default="",
)
@property
def under_18(self):
return (timezone.now().date() - self.birth_date).days < 18 * 365.24
@ -208,6 +201,13 @@ class StudentRegistration(ParticipantRegistration):
default="",
)
health_sheet = models.FileField(
verbose_name=_("health sheet"),
upload_to=get_random_health_filename,
blank=True,
default="",
)
@property
def type(self):
return _("student")

View File

@ -106,7 +106,7 @@ Signature pr\'ec\'ed\'ee de la mention \og lu et approuv\'e \fg{}
\begin{minipage}[c]{0.5\textwidth}
\underline{L'\'el\`eve :}\\
\underline{Le participant :}\\
Fait \`a :\\
le

View File

@ -57,7 +57,10 @@
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadPhotoAuthorizationModal">{% trans "Replace" %}</button>
{% endif %}
</dd>
{% endif %}
{% if user_object.registration.studentregistration %}
{% if user_object.registration.under_18 %}
<dt class="col-sm-6 text-right">{% trans "Health sheet:" %}</dt>
<dd class="col-sm-6">
{% if user_object.registration.health_sheet %}
@ -67,10 +70,7 @@
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadHealthSheetModal">{% trans "Replace" %}</button>
{% endif %}
</dd>
{% endif %}
{% if user_object.registration.studentregistration %}
{% if user_object.registration.under_18 %}
<dt class="col-sm-6 text-right">{% trans "Parental authorization:" %}</dt>
<dd class="col-sm-6">
{% if user_object.registration.parental_authorization %}

View File

@ -30,7 +30,7 @@ urlpatterns = [
path("photo-authorization-template/child/", ChildPhotoAuthorizationTemplateView.as_view(),
name="photo_authorization_child_template"),
path("instructions-template/", InstructionsTemplateView.as_view(), name="instructions_template"),
path("user/<int:pk>/upload-health_sheet/", UserUploadHealthSheetView.as_view(),
path("user/<int:pk>/upload-health-sheet/", UserUploadHealthSheetView.as_view(),
name="upload_user_health_sheet"),
path("user/<int:pk>/upload-parental-authorization/", UserUploadParentalAuthorizationView.as_view(),
name="upload_user_parental_authorization"),

Binary file not shown.