Improve security and minor improvement

This commit is contained in:
Gregory Trullemans 2024-04-19 11:01:23 +02:00
parent 170eecd104
commit 20293fbab7
11 changed files with 231 additions and 141 deletions

View File

@ -15,6 +15,7 @@ from jarvis.core.global_vars import (
CATEGORY_CHOICES,
AGE_CATOGORY_CHOICES,
NOTE_STATUS_CHOICES,
GENDER_CHOICES,
)
from jarvis.tools.models import Markdownizable, Seasonisable
@ -406,6 +407,33 @@ class HeightWeight(Seasonisable):
height = self.height / 100
return self.weight / (height * height)
@property
def bmi_quality(self):
bmi = self.bmi
if self.gymnast.gender == 0:
if bmi < 19:
return 2
elif bmi < 21:
return 1
elif bmi < 23:
return 0
elif bmi < 25:
return 1
else:
return 2
else:
if bmi < 21:
return 2
elif bmi < 23:
return 1
elif bmi < 25:
return 0
elif bmi < 27:
return 1
else:
return 2
def __str__(self):
return f"{self.gymnast} : {self.height}/{self.hips_height} - {self.weight}"

View File

@ -7,14 +7,19 @@
<div class="col-8">
<h4 class="">
{% if gymnast %}
<i><a href="{% url 'gymnast_details_tab' gymnast.id 'scores' %}">{{ gymnast }}</a></i>'s
{% endif %} chronos listing
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'scores' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} chronos
</h4>
</div>
<div class="col-1 ml-auto">
<div class="text-right">
<a
href="{% if gymnast %}{% url 'chrono_create_for_gymnast' gymnast.id %}{% else %}{% url 'chrono_create' %}{% endif %}">
<a href="{% if gymnast %}{% url 'chrono_create_for_gymnast' gymnast.id %}{% else %}{% url 'chrono_create' %}{% endif %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="fas fa-plus"></i>
</button>
@ -76,18 +81,13 @@
</div>
<div class="col-md-6 pl-0 pr-0 pt-3 row">
<div class="col-12">
<canvas id="chart_chrono" class="chartjs" width="100%">Your browser doesn't support canvas</canvas>
<canvas id="chart_chrono" class="chartjs" width="100%">
Your browser doesn't support canvas
</canvas>
</div>
<div class="col-12 text-center">
<p>{{ personnal_best.date | date:"l j F Y" }} : <b class="text-danger">{{ personnal_best.tof }}</b> (ToF) | <b>{{ personnal_best.score }}</b> sec</p>
</div>
<!-- <div class="col-4 text-center">
{{ personnal_best.tof }} (ToF)
</div>
<div class="col-4 text-left">
| {{ personnal_best.score }}sec
</div> -->
</div>
</div>
{% else %}
@ -117,7 +117,15 @@
<span class="far fa-search-plus text-warning"></span>
</a>
</td>
<td>{% if chrono.details.all %}<a href="{% url 'jump_chrono_details' chrono.id %}">{% endif %}{{ chrono.date | date:"j-n-Y" }}{% if chrono.details.all %}</a>{% endif %}</td>
<td>
{% if chrono.details.all %}
<a href="{% url 'jump_chrono_details' chrono.id %}">
{% endif %}
{{ chrono.date | date:"j-n-Y" }}
{% if chrono.details.all %}
</a>
{% endif %}
</td>
<td class="text-left">
{% if chrono.gymnast.id in request.session.available_gymnast or request.user.is_superuser %}<a href="{% url 'gymnast_details_tab' chrono.gymnast.id 'scores' %}">{% endif %}
{{ chrono.gymnast }}

View File

@ -8,7 +8,17 @@
<div class="card">
<div class="card-header row">
<div class="col-10 pr-0">
<h4 class="">{% if gymnast %}<a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}"><i>{{ gymnast }}</i></a>'s{% endif %} Height/Weight listing </h4>
<h4 class="">
{% if gymnast %}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} Height/Weight
</h4>
</div>
<div class="col-2 ml-auto pl-0">
<div class="text-right">
@ -47,37 +57,27 @@
</td>
<td class="text-left">{{ height_weight.date | date:"j-n-Y" }}</td>
<td class="text-center">{{ height_weight.height }}</td>
<td class="text-center">{% if height_weight.hips_height == None %}-{% else %}{{ height_weight.hips_height }}{% endif %}</td>
<td class="text-center">
{% if height_weight.hips_height == None %}
-
{% else %}
{{ height_weight.hips_height }}
{% endif %}
</td>
<td class="text-center">{{ height_weight.weight }}</td>
<td class="text-center">
{% if gymnast %}
{% if gymnast.gender == 0 %}
{% if height_weight.bmi < 19 %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 21 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 23 %}
<span class="text-success"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 25 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% else %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% endif %}
{% else %}
{% if height_weight.bmi < 21 %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 23 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 25 %}
<span class="text-success"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 27 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% else %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% endif %}
{% if height_weight.bmi_quality == 2 %}
<span class="text-danger">
{% elif height_weight.bmi_quality == 1 %}
<span class="text-warning">
{% elif height_weight.bmi_quality == 0 %}
<span class="text-success">
{% endif %}
{% else %}
<b>{{ height_weight.bmi | floatformat:2 }}</b>
{% endif %}
<b>{{ height_weight.bmi | floatformat:2 }}</b>
{% if gymnast %}
</span>
{% endif %}
</td>
</tr>
@ -86,78 +86,78 @@
</table>
</div>
<div class="col-md-6 pl-0 pr-0 pt-3">
<canvas id="chart_height_weight" class="chartjs" width="100%">Your browser doesn't support canvas</canvas>
<canvas id="chart_height_weight" class="chartjs" width="100%">
Your browser doesn't support canvas
</canvas>
</div>
</div>
{% else %}
{% if height_weight_list %}
<table class="table tablesorter table-striped mb-0" data-sort="table" id="height_weight_table">
<thead>
<tr>
<th></th>
<th class="header text-left">Date</th>
{% if not gymnast %}
<th class="header text-left">Gymnast</th>
{% endif %}
<th class="header text-center">Height</th>
<th class="header text-center">Hips height</th>
<th class="header text-center">Weight</th>
<th class="header text-center">BMI</th>
</tr>
</thead>
<tbody>
{% for height_weight in height_weight_list %}
<tr>
<td>
<a href="{% url 'height_weight_update' height_weight.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-left">{{ height_weight.date | date:"j-n-Y" }}</td>
{% if not gymnast %}
<td class="text-left">{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}<a href="{% url 'gymnast_details' height_weight.gymnast.id %}">{% endif %}{{ height_weight.gymnast }}</a></td>
{% endif %}
<td class="text-center">{{ height_weight.height }}</td>
<td class="text-center">{% if height_weight.hips_height == None %}-{% else %}{{ height_weight.hips_height }}{% endif %}</td>
<td class="text-center">{{ height_weight.weight }}</td>
<td class="text-center">
{% if gymnast %}
{% if gymnast.gender == 0 %}
{% if height_weight.bmi < 19 %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 21 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 23 %}
<span class="text-success"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 25 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% else %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% endif %}
{% if height_weight_list %}
<table class="table tablesorter table-striped mb-0" data-sort="table" id="height_weight_table">
<thead>
<tr>
<th></th>
<th class="header text-left">Date</th>
{% if not gymnast %}
<th class="header text-left">Gymnast</th>
{% endif %}
<th class="header text-center">Height</th>
<th class="header text-center">Hips height</th>
<th class="header text-center">Weight</th>
<th class="header text-center">BMI</th>
</tr>
</thead>
<tbody>
{% for height_weight in height_weight_list %}
<tr>
<td>
<a href="{% url 'height_weight_update' height_weight.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-left">{{ height_weight.date | date:"j-n-Y" }}</td>
{% if not gymnast %}
<td class="text-left">
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details' height_weight.gymnast.id %}">
{% endif %}
{{ height_weight.gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}
</td>
{% endif %}
<td class="text-center">{{ height_weight.height }}</td>
<td class="text-center">
{% if height_weight.hips_height == None %}
-
{% else %}
{% if height_weight.bmi < 21 %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 23 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 25 %}
<span class="text-success"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% elif height_weight.bmi < 27 %}
<span class="text-warning"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{% else %}
<span class="text-danger"><b>{{ height_weight.bmi | floatformat:2 }}</b></span>
{{ height_weight.hips_height }}
{% endif %}
</td>
<td class="text-center">{{ height_weight.weight }}</td>
<td class="text-center">
{% if gymnast %}
{% if height_weight.bmi_quality == 2 %}
<span class="text-danger">
{% elif height_weight.bmi_quality == 1 %}
<span class="text-warning">
{% elif height_weight.bmi_quality == 0 %}
<span class="text-success">
{% endif %}
{% endif %}
{% else %}
<b>{{ height_weight.bmi | floatformat:2 }}</b>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">There are no scores corresponding to your criterias</p>
{% endif %}
{% if gymnast %}
</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">There are no scores corresponding to your criterias</p>
{% endif %}
{% endif %}
</div>
</div>

View File

@ -5,7 +5,17 @@
<div class="card-header">
<div class="row">
<div class="col-md-4">
<h4 class="">{% if gymnast %}<i><a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}">{{ gymnast }}</a></i>'s{% endif %} injuries Listing</h4>
<h4 class="">
{% if gymnast %}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} injuries
</h4>
</div>
<div class="col-1 ml-auto">
<div class="text-right">
@ -47,13 +57,13 @@
<td class="text-left"><a href="{% url 'injury_details' injury.id %}">{{ injury.date | date:"j-n-Y" }}</a></td>
{% if not gymnast %}
<td class="text-left">
{% if injury.gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' injury.gymnast.id 'physiological' %}">
{% endif %}
{{ injury.gymnast }}
{% if injury.gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}
{% if injury.gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' injury.gymnast.id 'physiological' %}">
{% endif %}
{{ injury.gymnast }}
{% if injury.gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}
</td>
{% endif %}
<td class="text-left">{{ injury.get_mechanism_display }}</td>

View File

@ -6,7 +6,15 @@
<div class="row">
<div class="col-8">
<h4 class="">
{% if gymnast %}<i><a href="{% url 'gymnast_details_tab' gymnast.id 'routine' %}">{{ gymnast }}</a></i>'s{% endif %} Intensity listing
{% if gymnast %}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'routine' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} Intensities
</h4>
</div>
<div class="col-1 ml-auto">
@ -69,12 +77,13 @@
<td class="text-center">
<b>
{% if intensity.average_training_quality <= 85.0 %}
<span class="text-danger">{{ intensity.average_training_quality | floatformat:1 }}%</span>
<span class="text-danger">
{% elif intensity.average_training_quality <= 95.0 %}
<span class="text-warning">{{ intensity.average_training_quality | floatformat:1 }}%</span>
<span class="text-warning">
{% else %}
<span class="text-success">{{ intensity.average_training_quality | floatformat:1 }}%</span>
<span class="text-success">
{% endif %}
{{ intensity.average_training_quality | floatformat:1 }}%</span>
</b>
</td>
@ -82,12 +91,13 @@
<td class="text-center">
<b>
{% if intensity.passes_quality_for_gymnast >= 3 %}
<span class="text-danger">{{ intensity.average_time_by_passe_readable }}</span>
<span class="text-danger">
{% elif intensity.passes_quality_for_gymnast == 2 %}
<span class="text-warning">{{ intensity.average_time_by_passe_readable }}</span>
<span class="text-warning">
{% else %}
<span class="text-success">{{ intensity.average_time_by_passe_readable }}</span>
<span class="text-success">
{% endif %}
{{ intensity.average_time_by_passe_readable }}</span>
</b>
</td>
<!-- Difficulty by passe -->

View File

@ -6,7 +6,15 @@
<div class="row">
<div class="col-8">
<h4 class="">
{% if gymnast %}<i><a href="{% url 'gymnast_details_tab' gymnast.id 'event' %}">{{ gymnast }}</a></i>'s{% endif %} notes listing
{% if gymnast %}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'event' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} notes
</h4>
</div>
<div class="col-1 ml-auto">

View File

@ -9,11 +9,14 @@
<div class="col-8">
<h4 class="">
{% if gymnast %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'routine' %}">
<i>{{ gymnast }}</i>
</a>'s
{% endif %}
routine done listing
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'routine' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} routine done
</h4>
</div>
<div class="col-1 ml-auto">
@ -57,9 +60,11 @@
</td>
<td class="text-left">
{% if routine_done.routine %}
<a href="{% url 'combination_details' routine_done.routine.id %}">{{ routine_done.routine.long_label }}</a>
<a href="{% url 'combination_details' routine_done.routine.id %}">
{{ routine_done.routine.long_label }}
</a>
{% else %}
-
-
{% endif %}
</td>
<td class="text-center">

View File

@ -8,7 +8,15 @@
<div class="card-header row">
<div class="col-8">
<h4 class="">
{% if gymnast %}<a href="{% url 'gymnast_details_tab' gymnast.id 'scores' %}"><i>{{ gymnast }}</i></a>'s {% endif %} Scores listing
{% if gymnast %}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'scores' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} Scores
</h4>
</div>
<div class="col-1 ml-auto">
@ -33,8 +41,8 @@
<th class="header text-left">Gymnast</th>
{% endif %}
<th class="header text-left">Event</th>
<th class="header text-left">Date</th>
<th class="header text-left">Routine</th>
<th class="header text-center">Date</th>
<th class="header text-center">Routine</th>
<th class="header text-center">Exe.</th>
<th class="header text-center">Dif.</th>
<th class="header text-center">ToF</th>
@ -52,7 +60,15 @@
</a>
</td>
{% if not gymnast %}
<td>{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}<a href="{% url 'gymnast_details' score.gymnast.id %}">{% endif %}{{ score.gymnast }}</a></td>
<td>
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details' score.gymnast.id %}">
{% endif %}
{{ score.gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}
</td>
{% endif %}
<td><a href="{% url 'event_details' score.event.id %}">{{ score.event.name }}</a></td>
<td class="text-center">{{ score.event.date_begin | date:"j-n-Y" }}</td>
@ -62,9 +78,12 @@
<td class="text-center">{{ score.point_time_of_flight }}</td>
<td class="text-center">{{ score.point_horizontal_displacement }}</td>
<td class="text-center">
{% if score.penality > 0 %}-{{ score.penality }}
{% else %}-
{% endif %}</td>
{% if score.penality > 0 %}
-{{ score.penality }}
{% else %}
-
{% endif %}
</td>
<td class="text-center"><b>{{ score.total }}</b></td>
</tr>
{% endfor %}

View File

@ -10,16 +10,14 @@
<div class="col-10 pr-0">
<h4 class="">
{% if gymnast %}
<i>
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}">
{% endif %}
{{ gymnast }}
</i>
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} Well being listing
{% endif %} Well beings
</h4>
</div>
<div class="col-2 ml-auto pl-0">

View File

@ -6,7 +6,11 @@
<div class="card-header">
<div class="row">
<div class="col-6">
<h4 class="mb-0">{% if gymnast %}<a href="{% url 'gymnast_details_tab' gymnast.id 'event' %}">{{ gymnast }}</a>'s {% endif %}Event Listing</h4>
<h4 class="mb-0">
{% if gymnast %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'event' %}">{{ gymnast }}</a>'s
{% endif %} Events
</h4>
{% if event_list %}<a href="{% url 'calendar' %}" class="mb-3">Calendar</a>{% endif %}
</div>
<div class="col-1 ml-auto">

View File

@ -188,7 +188,7 @@ def event_listing(request, gymnast_id=None):
gymnast = None
event_list = __get_event_list(request)
context = {"event_list": event_list, "gymnast":gymnast}
context = {"event_list": event_list, "gymnast": gymnast}
return render(request, "events/list.html", context)