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> <dt class="col-sm-6 text-right">{% trans "Health sheets:" %}</dt>
<dd class="col-sm-6"> <dd class="col-sm-6">
{% for participant in team.participants.all %} {% for student in team.students.all %}
{% if participant.health_sheet %} {% if student.under_18 %}
<a href="{{ participant.health_sheet.url }}" data-turbolinks="false">{{ participant }}</a>{% if not forloop.last %},{% endif %} {% if student.health_sheet %}
{% else %} <a href="{{ student.health_sheet.url }}" data-turbolinks="false">{{ student }}</a>{% if not forloop.last %},{% endif %}
{{ participant }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %} {% else %}
{{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</dd> </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 \ 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.email_confirmed for r in team.students.all()) and \
all(r.photo_authorization for r in team.participants.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) all(r.parental_authorization for r in team.students.all() if r.under_18)
return context 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="", default="",
) )
health_sheet = models.FileField(
verbose_name=_("health sheet"),
upload_to=get_random_health_filename,
blank=True,
default="",
)
@property @property
def under_18(self): def under_18(self):
return (timezone.now().date() - self.birth_date).days < 18 * 365.24 return (timezone.now().date() - self.birth_date).days < 18 * 365.24
@ -208,6 +201,13 @@ class StudentRegistration(ParticipantRegistration):
default="", default="",
) )
health_sheet = models.FileField(
verbose_name=_("health sheet"),
upload_to=get_random_health_filename,
blank=True,
default="",
)
@property @property
def type(self): def type(self):
return _("student") 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} \begin{minipage}[c]{0.5\textwidth}
\underline{L'\'el\`eve :}\\ \underline{Le participant :}\\
Fait \`a :\\ Fait \`a :\\
le le

View File

@ -57,20 +57,20 @@
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadPhotoAuthorizationModal">{% trans "Replace" %}</button> <button class="btn btn-primary" data-toggle="modal" data-target="#uploadPhotoAuthorizationModal">{% trans "Replace" %}</button>
{% endif %} {% endif %}
</dd> </dd>
<dt class="col-sm-6 text-right">{% trans "Health sheet:" %}</dt>
<dd class="col-sm-6">
{% if user_object.registration.health_sheet %}
<a href="{{ user_object.registration.health_sheet.url }}" data-turbolinks="false">{% trans "Download" %}</a>
{% endif %}
{% if user_object.registration.team and not user_object.registration.team.participation.valid %}
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadHealthSheetModal">{% trans "Replace" %}</button>
{% endif %}
</dd>
{% endif %} {% endif %}
{% if user_object.registration.studentregistration %} {% if user_object.registration.studentregistration %}
{% if user_object.registration.under_18 %} {% 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 %}
<a href="{{ user_object.registration.health_sheet.url }}" data-turbolinks="false">{% trans "Download" %}</a>
{% endif %}
{% if user_object.registration.team and not user_object.registration.team.participation.valid %}
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadHealthSheetModal">{% trans "Replace" %}</button>
{% endif %}
</dd>
<dt class="col-sm-6 text-right">{% trans "Parental authorization:" %}</dt> <dt class="col-sm-6 text-right">{% trans "Parental authorization:" %}</dt>
<dd class="col-sm-6"> <dd class="col-sm-6">
{% if user_object.registration.parental_authorization %} {% if user_object.registration.parental_authorization %}

View File

@ -30,7 +30,7 @@ urlpatterns = [
path("photo-authorization-template/child/", ChildPhotoAuthorizationTemplateView.as_view(), path("photo-authorization-template/child/", ChildPhotoAuthorizationTemplateView.as_view(),
name="photo_authorization_child_template"), name="photo_authorization_child_template"),
path("instructions-template/", InstructionsTemplateView.as_view(), name="instructions_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"), name="upload_user_health_sheet"),
path("user/<int:pk>/upload-parental-authorization/", UserUploadParentalAuthorizationView.as_view(), path("user/<int:pk>/upload-parental-authorization/", UserUploadParentalAuthorizationView.as_view(),
name="upload_user_parental_authorization"), name="upload_user_parental_authorization"),

Binary file not shown.