Minors improvements

This commit is contained in:
Gregory Trullemans 2024-04-09 19:32:01 +02:00
parent 0a27daad50
commit 6074f7b1a3
16 changed files with 118 additions and 186 deletions

View File

@ -93,7 +93,7 @@
</li>
{% menuitem 'next_event_list' 'fal fa-calendar-alt' 'Events' %}
{% if request.user|has_group:"trainer" %}
{% menuitem 'injuries_list' 'fal fa-comment-alt-medical' 'Injuries' %}
{% menuitem 'injury_list' 'fal fa-comment-alt-medical' 'Injuries' %}
{% endif %}
{% menuitem 'place_list' 'fal fa-map-marked-alt' 'Places' %}
{% if request.user|has_group:"trainer" %}

View File

@ -21,7 +21,7 @@
<div class="card-footer row">
<div class="col-6">
<a href="{% url 'injuries_list' %}">
<a href="{% url 'injury_list' %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="tim-icons icon-double-left"></i>
</button>

View File

@ -5,7 +5,7 @@
<div class="card-header">
<div class="row">
<div class="col-md-4">
<h4 class=""> Injuries Listing</h4>
<h4 class="">{% if gymnast %}<i><a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}">{{ gymnast }}</a></i>'s{% endif %} injuries Listing</h4>
</div>
<div class="col-1 ml-auto">
<div class="text-right">
@ -20,13 +20,15 @@
</div>
<div class="card-body">
<div class="table-responsive">
{% if injuries_list %}
{% if injury_list %}
<table class="table tablesorter table-striped" data-sort="table" id="injury_table">
<thead class="text-primary">
<tr>
<th style="width: 3%"></th>
<th class="header text-left" style="width: 8%">Date</th>
<th class="header text-left" style="width: 20%">Gymnast</th>
{% if not gymnast %}
<th class="header text-left" style="width: 20%">Gymnast</th>
{% endif %}
<th class="header text-left" style="width: 9%">Mechanism</th>
<th class="header text-left" style="width: 20%">Location</th>
<th class="header text-left" style="width: 8%">Side</th>
@ -35,7 +37,7 @@
</tr>
</thead>
<tbody>
{% for injury in injuries_list %}
{% for injury in injury_list %}
<tr role="row" class="{% cycle 'odd' 'even' %}">
<td>
<a href="{% url 'injury_update' injury.id %}">
@ -43,7 +45,17 @@
</a>
</td>
<td class="text-left"><a href="{% url 'injury_details' injury.id %}">{{ injury.date | date:"j-n-Y" }}</a></td>
<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 }}</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 %}
</td>
{% endif %}
<td class="text-left">{{ injury.get_mechanism_display }}</td>
<td class="text-left">{{ injury.get_location_display }}</td>
<td class="text-left">{{ injury.get_body_side_display }}</td>

View File

@ -65,7 +65,7 @@ class URLTestCase(TestCase):
self.assertEqual(
resolve("/follow-up/injury/search/").view_name, "injury_search"
)
self.assertEqual(resolve("/follow-up/injury/").view_name, "injuries_list")
self.assertEqual(resolve("/follow-up/injury/").view_name, "injury_list")
self.assertEqual(resolve("/follow-up/injury/add/").view_name, "injury_create")
self.assertEqual(
resolve("/follow-up/injury/add/1/").view_name,

View File

@ -165,8 +165,12 @@ urlpatterns = [
#
#
# ACCIDENT
path(r"injury/search/", views_physiological.injuries_listing, name="injury_search"),
path(r"injury/", views_physiological.injuries_listing, name="injuries_list"),
path(r"injury/search/", views_physiological.injury_listing, name="injury_search"),
path(r"injury/", views_physiological.injury_listing, name="injury_list"),
path(
r"injury/gymnast/<int:gymnast_id>/",
views_physiological.injury_listing,
name="injury_list_for_gymnast"),
path(
r"injury/add/",
views_physiological.injury_create_or_update,

View File

@ -34,7 +34,7 @@ from .email_vars import MAIL_HEADER, MAIL_FOOTER
@login_required
@require_http_methods(["GET"])
def injuries_listing(request, gymnast_id=None):
def injury_listing(request, gymnast_id=None):
"""
Récupère la liste des bessures.
Si c'est un gymnaste qui est connecté, il ne peut récupérer que la liste de ses blessures.
@ -51,16 +51,16 @@ def injuries_listing(request, gymnast_id=None):
)
):
gymnast = get_object_or_404(Gymnast, pk=gymnast_id)
injuries_list = Injury.objects.filter(gymnast=gymnast_id)
injury_list = Injury.objects.filter(gymnast=gymnast_id)
else:
if request.user.is_superuser:
injuries_list = Injury.objects.all()
injury_list = Injury.objects.all()
else:
injuries_list = Injury.objects.filter(
injury_list = Injury.objects.filter(
gymnast__in=request.session["available_gymnast"]
)
context = {"injuries_list": injuries_list, "gymnast": gymnast}
context = {"injury_list": injury_list, "gymnast": gymnast}
return render(request, "injuries/list.html", context)
@ -152,7 +152,7 @@ def injury_details(request, injury_id):
request.session.has_key("available_gymnast")
and injury.gymnast.id not in request.session["available_gymnast"]
):
return injuries_listing(request)
return injury_listing(request)
return render(request, "injuries/details.html", {"injury": injury})

View File

@ -69,8 +69,9 @@ def compute_completude(total_skill, gymnast_nb_known_skills, max_level_skill):
max_skill (int): nombre maximum de skill.
Returns:
string: pourcentage de skill connus.
string: pourcentage de skill connus sous forme de string.
int: niveau estimé du gymnaste.
float: pourcentage de skill connus sous forme de nombre
Example:
>>> from jarvis.objective.tools import compute_completude
@ -80,11 +81,12 @@ def compute_completude(total_skill, gymnast_nb_known_skills, max_level_skill):
if total_skill:
percentage = gymnast_nb_known_skills / total_skill
completude = f"{int(percentage * 100)}%"
evaluated_level = int(max_level_skill * percentage)
estimated_level = int(max_level_skill * percentage)
else:
percentage = 0
completude = None
evaluated_level = None
return completude, evaluated_level
estimated_level = None
return completude, estimated_level, int(percentage * 100)
def compute_statistics_by_type(

View File

@ -221,7 +221,7 @@ class Gymnast(Markdownizable):
"""
Calcule toutes les statistiques par rapport au niveau/rang suivant le paramètre transmis.
1. On va chercher le niveau/rang maximum de skill que le gymnast sait faire
1. On va chercher le type (niveau ou rang) maximum de skill que le gymnast sait faire
2. 0n va chercher le nombre de skill par niveau/rang que le gymnast sait faire
nb_known_skill_by_type = [
{
@ -259,6 +259,7 @@ class Gymnast(Markdownizable):
context = {}
skill_max = self.skill_max_for_type(desired_type)
gymnast_nb_known_skills = self.known_skills.distinct("skill").count()
context["gymnast_nb_known_skills"] = gymnast_nb_known_skills
if skill_max > 0:
cpt_known_skill_by_type = self.nb_known_skill_by_type(
@ -275,10 +276,16 @@ class Gymnast(Markdownizable):
tmp = Skill.objects.all()
context["total_skill"] = tmp.count()
context["unknown_skill"] = tmp
context["percentages"] = 0
context["completude"], context["evaluated_level"] = compute_completude(
context["completude"], context["estimated_level"], context["percentage_known_skill"] = compute_completude(
context["total_skill"], gymnast_nb_known_skills, skill_max
)
# print(context["percentage_known_skill"])
# print(context["gymnast_nb_known_skills"])
# print(context["completude"])
# print(context["estimated_level"])
context["max_" + desired_type + "_skill"] = skill_max
return context

View File

@ -61,11 +61,11 @@
</div>
<div class="col-12 col-md-4 card">
{% if gymnast_nb_known_skills %}
{% generate_level_chart_bar gymnast.id %}
{% else %}
<p class="text-muted mt-3">No level/rank information.</p>
{% endif %}
{% if gymnast_nb_known_skills %}
{% generate_level_chart_bar gymnast.id %}
{% else %}
<p class="text-muted mt-3">No level/rank information.</p>
{% endif %}
</div>
</div>
@ -76,19 +76,7 @@
<li class="nav-item">
<a class="nav-link get-info{% if tab is None or tab == 'level' %} active{% endif %}" data-toggle="tab" href="#skill" data-ref="#skill" data-url="skill/" id="display_skill">
<i class="tim-icons icon-sound-wave"></i> <!-- Level -->
</a>
</li>
<li class="nav-item">
<a class="nav-link get-info{% if tab == 'season_informations' %} active{% endif %}" data-toggle="tab" href="#season_informations" data-ref="#season_informations" data-url="season_informations/" id="display_season_informations">
<i class="fal fa-map-signs"></i> <!-- Season Informations -->
</a>
</li>
<li class="nav-item">
<a class="nav-link get-info{% if tab == 'document' %} active{% endif %}" data-toggle="tab" href="#document" data-ref="#document" data-url="document/" id="display_documents">
<i class="fal fa-file-pdf"></i> <!-- Documents -->
<i class="fal fa-hexagon"></i> <!-- Level -->
</a>
</li>
@ -100,7 +88,7 @@
<li class="nav-item">
<a class="nav-link get-info{% if tab == 'scores' %} active{% endif %}" data-toggle="tab" href="#scores" data-ref="#scores" data-url="scores_chrono/" id="display_scores_chrono">
<i class="fal fa-crosshairs"></i> <!-- Scores -->
<i class="fal fa-tasks-alt"></i> <!-- Scores -->
</a>
</li>
@ -111,10 +99,22 @@
</li>
<li class="nav-item">
<a class="nav-link get-info{% if tab == 'event' %} active{% endif %} mr-2 mb-1" data-toggle="tab" href="#event" data-ref="#event" data-url="event/" id="display_event">
<a class="nav-link get-info{% if tab == 'event' %} active{% endif %}" data-toggle="tab" href="#event" data-ref="#event" data-url="event/" id="display_event">
<i class="fal fa-calendar-day"></i> <!-- Events -->
</a>
</li>
<li class="nav-item">
<a class="nav-link get-info{% if tab == 'season_informations' %} active{% endif %}" data-toggle="tab" href="#season_informations" data-ref="#season_informations" data-url="season_informations/" id="display_season_informations">
<i class="fal fa-map-signs"></i> <!-- Season Informations -->
</a>
</li>
<li class="nav-item">
<a class="nav-link get-info{% if tab == 'document' %} active{% endif %} mr-2 mb-1" data-toggle="tab" href="#document" data-ref="#document" data-url="document/" id="display_documents">
<i class="fal fa-file-pdf"></i> <!-- Documents -->
</a>
</li>
</ul>
</div>
<div class="col-12 col-sm-11 col-md-11 col-lg-11 pr-0">

View File

@ -1,5 +1,5 @@
<h4 class="d-flex align-items-end flex-column">
Estimated level : {% if gymnast_nb_known_skills %}{{ evaluated_level }}{% else %}0{% endif %}
Estimated level : {% if gymnast_nb_known_skills %}{{ estimated_level }}{% else %}0{% endif %}
</h4>
<div class="progress-container progress-primary">
<div class="progress" style="height: 10px;">

View File

@ -5,7 +5,7 @@
<h4>Injuries</h4>
</div>
<div class="card-body pt-0 pb-0">
{% if injuries_list %}
{% if injury_list %}
<div class="card-body pl-0 pt-0 pr-0">
<table class="table table-striped table-condensed tablesorter mb-1">
<thead>
@ -16,7 +16,7 @@
</tr>
</thead>
<tbody>
{% for injury in injuries_list %}
{% for injury in injury_list %}
<tr>
<td class="text-left">
<a href="{% url 'injury_update' injury.id %}">

View File

@ -214,7 +214,7 @@
<div class="row">
<div class="col-12">
<h4 class="mb-1">Injury</h4>
{% if injuries_list %}
{% if injury_list %}
<table class="table" id="injury_table">
<thead class="text-primary">
<tr>
@ -228,7 +228,7 @@
</tr>
</thead>
<tbody>
{% for injury in injuries_list %}
{% for injury in injury_list %}
<tr role="row" class="{% cycle 'odd' 'even' %}">
<td class="text-left">{{ injury.date | date:"d-m-Y" }}</td>
<td class="text-left">{{ injury.gymnast }}</td>

View File

@ -5,21 +5,25 @@
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="mb-0">{{ latest_published_note.title }}</h4>
<p class="text-muted">{{ latest_published_note.date | date:'j N Y' }}</p>
<div class="row">
<div class="col-8">
<h4 class="mb-0">{{ latest_published_note.title }}</h4>
<p class="text-muted">{{ latest_published_note.date | date:'j N Y' }}</p>
</div>
{% if request.user.id == latest_published_note.coach.id %}
<div class="col-1 ml-auto text-right">
<a href="{% url 'note_update' latest_published_note.id %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<span class="tim-icons icon-pencil"></span>
</button>
</a>
</div>
{% endif %}
</div>
</div>
<div class="card-body pt-0">
<div class="card-body pt-0 text-justify">
<p>{{ latest_published_note.to_markdown | safe }}</p>
</div>
<div class="card-footer text-right text-muted pt-0">
{% if request.user.id == latest_published_note.coach.id %}
<a href="{% url 'note_update' latest_published_note.id %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<span class="tim-icons icon-pencil"></span>
</button>
</a>
{% endif %}
</div>
</div>
</div>
</div>

View File

@ -16,7 +16,7 @@
{% if height_weight_list %}
<a href="{% url 'heightweight_list_for_gymnast' gymnast_id %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="fal fa-line-height"></i>
<i class="fal fa-weight"></i>
</button>
</a>
{% endif %}
@ -64,10 +64,10 @@
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4>Injuries ({{ number_of_injuries }})</h4>
<h4>Injuries <i>on two last month</i></h4>
</div>
<div class="card-body pt-0 pb-0">
{% if injuries_list %}
{% if injury_list %}
<table class="table tablesorter table-striped table-condensed" id="injury_table">
<thead>
<tr>
@ -82,7 +82,7 @@
</tr>
</thead>
<tbody>
{% for injury in injuries_list %}
{% for injury in injury_list %}
<tr>
<td class="text-left">
<a href="{% url 'injury_update' injury.id %}">
@ -105,6 +105,13 @@
{% endif %}
</div>
<div class="card-footer text-right text-muted pt-0">
{% if injury_list %}
<a href="{% url 'injury_list_for_gymnast' gymnast_id %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="fal fa-comment-alt-medical"></i>
</button>
</a>
{% endif %}
<a href="{% url 'injury_create_for_gymnast' gymnast_id %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="fas fa-plus"></i>

View File

@ -23,7 +23,7 @@
</div>
<div class="card-body pt-0">
{% if season_information_list %}
<table class="table tablesorter table-striped mb-0" data-sort="table" id="score_table">
<table class="table tablesorter table-striped mb-0" data-sort="table" id="season_informations_table">
<thead>
<tr>
<th></th>
@ -62,126 +62,22 @@
</div>
<script type="text/javascript">
$(document).ready(function () {
$('[data-sort="table"]').tablesorter({
headers: {
0: { sorter: false },
},
dateFormat: "uk",
sortList: [[2, 1]]
});
$('#span_week_button_generate').hide();
$('#span_week_comparison_button_generate').hide();
$('#span_month_button_generate').hide();
$('#span_season_button_generate').hide();
function check_comparison_fields(){
alert("check comparison fields")
if($('#select_week_number1').val() == '')
return false;
if($('#select_week_number2').val() == '')
return false;
if ($('#select_week_number2').val() == $('#select_week_number2').val())
return false;
return true;
}
function show_comparison_button(){
var tmp_url = "{% url 'gymnast_generate_report_week_comparison' gymnast.id '_season_source_' 9999 '_season_target_' 8888 %}";
season_source = $('#select_season_for_week1').val()
week_source = $('#select_week_number1').val()
season_target = $('#select_season_for_week2').val()
week_target = $('#select_week_number2').val()
target_url = tmp_url.replace('_season_source_', season_source).replace('9999', week_source).replace('_season_target_', season_target).replace('8888', week_target);
$('#week_comprison_pdf_link').attr('href', target_url);
$('#span_week_comparison_button_generate').show()
}
$('#select_season_for_week').change(function(){
var tmp_url = "{% url 'get_distinct_week_number_for_season_and_gymnast' gymnast.id '_season_label_' %}";
var season_label = $(this).children("option:selected").val();
target_url = tmp_url.replace('_season_label_', season_label);
$.getJSON(target_url, function(data) {
if (!$.trim(data))
$('#week_management').hide();
else
$('#week_management').show();
$("#select_week_number option").remove(); // Remove all <option> child tags.
$.each(data, function(key, value) { // Iterates through a collection
$("#select_week_number").append( // Append an object to the inside of the select box
$("<option></option>").text(value).val(value)
);
});
$('#score_table').DataTable({
scrollY: '50vh',
scrollCollapse: true,
paging: false,
searching: false,
ordering: false,
// "bInfo" : false,
});
});
$('#select_season_for_week1').change(function(){
var test = check_comparison_fields();
if(test)
show_comparison_button();
else
$('#span_week_comparison_button_generate').hide();
});
$('#select_week_number1').change(function(){
var test = check_comparison_fields();
if(test)
show_comparison_button();
else
$('#span_week_comparison_button_generate').hide();
});
$('#select_season_for_week2').change(function(){
var test = check_comparison_fields();
if(test)
show_comparison_button();
else
$('#span_week_comparison_button_generate').hide();
});
$('#select_week_number2').change(function(){
var test = check_comparison_fields();
if(test)
show_comparison_button();
else
$('#span_week_comparison_button_generate').hide();
});
$('#select_week_number').change(function(){
if ($('#select_week_number').val() != "") {
var tmp_url = "{% url 'gymnast_report_export_for_week_number' gymnast.id '_season_label_' 9999 %}";
var season_label = $('#select_season_for_week').children("option:selected").val();
var week_number = $('#select_week_number').children("option:selected").val();
target_url = tmp_url.replace('_season_label_', season_label).replace('9999', week_number);
$('#week_pdf_link').attr('href', target_url);
$('#span_week_button_generate').show();
} else
$('#span_week_button_generate').hide();
});
$('#select_month_number').change(function(){
if ($('#select_month_number').val() != "") {
var tmp_url = "{% url 'gymnast_report_export_for_month_number' gymnast.id '_season_label_' 9999 %}";
var season_label = $('#select_season_for_month').children("option:selected").val();
var month_number = $('#select_month_number').children("option:selected").val();
target_url = tmp_url.replace('_season_label_', season_label).replace('9999', month_number);
$('#month_pdf_link').attr('href', target_url);
$('#span_month_button_generate').show();
} else
$('#span_month_button_generate').hide();
});
$('#select_season').change(function(){
if ($('#select_season').val() != "") {
var tmp_url = "{% url 'gymnast_report_export_for_season' gymnast.id '_season_label_' %}";
var season_label = $('#select_season').children("option:selected").val();
target_url = tmp_url.replace('_season_label_', season_label);
$('#season_pdf_link').attr('href', target_url);
$('#span_season_button_generate').show();
} else
$('#span_season_button_generate').hide();
});
</script>

View File

@ -228,8 +228,8 @@ def gymnast_display_physiological(request, gymnast_id):
gymnast_id (int) identifiant du gymnast
"""
number_of_injuries = Injury.objects.filter(gymnast=gymnast_id).count()
start_date = pendulum.now().date().subtract(months=6)
injuries_list = Injury.objects.filter(
start_date = pendulum.now().date().subtract(months=2)
injury_list = Injury.objects.filter(
gymnast=gymnast_id, date__gte=start_date
).order_by("date")
wellbeing_list = WellBeing.objects.filter(
@ -240,7 +240,7 @@ def gymnast_display_physiological(request, gymnast_id):
).order_by("date")
context = {
"injuries_list": injuries_list,
"injury_list": injury_list,
"number_of_injuries": number_of_injuries,
"wellbeing_list": wellbeing_list,
"height_weight_list": height_weight_list,