Update wellbeing listing

This commit is contained in:
Gregory Trullemans 2023-10-11 12:12:01 +02:00
parent ae7153565c
commit 0a42d3febf
9 changed files with 160 additions and 27 deletions

View File

@ -14,6 +14,7 @@ from .models import (
Injury,
WellBeing,
Intensity,
InjuryType,
HeightWeight,
LearnedSkill,
ChronoDetails,
@ -100,6 +101,14 @@ class InjuryLocationAdmin(admin.ModelAdmin):
search_fields = ("label",)
class InjuryTypeAdmin(admin.ModelAdmin):
model = InjuryType
list_display = ("label",)
fields = ("label",)
search_fields = ("label",)
class InjuryAdmin(admin.ModelAdmin):
model = Injury
@ -307,6 +316,7 @@ admin.site.register(Chrono, ChronoAdmin)
admin.site.register(Injury, InjuryAdmin)
admin.site.register(WellBeing, WellBeingAdmin)
admin.site.register(Intensity, IntensityAdmin)
admin.site.register(InjuryType, InjuryTypeAdmin)
admin.site.register(LearnedSkill, LearnedSkillAdmin)
admin.site.register(HeightWeight, HeightWeightAdmin)
admin.site.register(ChronoDetails, ChronoDetailsAdmin)

View File

@ -188,6 +188,7 @@ class InjuryForm(forms.ModelForm):
"gymnast",
"date",
"mechanism",
"injury_type",
"location",
"body_side",
"nb_week_off",
@ -204,6 +205,7 @@ class InjuryForm(forms.ModelForm):
),
"gymnast": forms.HiddenInput(),
"skill": forms.HiddenInput(),
"injury_type": forms.Select(attrs={"class": "form-control selectpicker"}),
"mechanism": forms.Select(attrs={"class": "form-control selectpicker"}),
"location": forms.Select(attrs={"class": "form-control selectpicker"}),
"body_side": forms.Select(attrs={"class": "form-control selectpicker"}),
@ -313,7 +315,7 @@ class WellBeingForm(forms.ModelForm):
"informations": forms.Textarea(
attrs={
"class": "form-control",
"placeholder": "Informations about your well being : context (why, where, …), possible consequencies, …", # pylint: disable=line-too-long
"placeholder": "Informations about the weel being state : context (why, where, when, …), possible consequencies, …", # pylint: disable=line-too-long
}
),
}

View File

@ -161,6 +161,21 @@ class InjuryLocation(models.Model):
return f"{self.label}"
class InjuryType(models.Model):
"""
Classe représentant les types de blessures
"""
class Meta:
verbose_name = "Injury Type"
verbose_name_plural = "Injury Types"
label = models.CharField(max_length=100, null=False, blank=False)
def __str__(self):
return f"{self.label}"
class Injury(Markdownizable, Seasonisable):
"""
La classe `Injury` permet d'indiquer qu'un gymnaste a eu un blessure, en liaison avec un
@ -193,6 +208,15 @@ class Injury(Markdownizable, Seasonisable):
related_name="injuries",
on_delete=models.CASCADE,
)
injury_type = models.ForeignKey(
InjuryType,
verbose_name="Injury Type",
related_name="injuries",
on_delete=models.SET_NULL,
default=None,
blank=True,
null=True,
)
body_side = models.PositiveSmallIntegerField(
choices=INJURY_BODY_SIDE_CHOICE, verbose_name="Body side"
)
@ -369,6 +393,18 @@ class WellBeing(Markdownizable, Seasonisable):
def __str__(self):
return f"{self.gymnast} - {self.date} : {self.mindstate} | {self.sleep} | {self.stress} | {self.fatigue} | {self.muscle_soreness}"
@property
def get_inversed_stress(self):
return 10 - self.stress
@property
def get_inversed_fatigue(self):
return 10 - self.fatigue
@property
def get_inversed_muscle_soreness(self):
return 10 - self.muscle_soreness
class GymnastHasRoutine(models.Model):
"""

View File

@ -47,6 +47,13 @@
{% if form.mechanism.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.mechanism.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_injury_type" class="col-4 col-sm-3 col-form-label">{{ form.injury_type.label }}<span class="text-danger"><b>*</b></span></label>
<div class="col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.injury_type.errors %}has-danger{% endif %}">
{{ form.injury_type }}
{% if form.injury_type.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.injury_type.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_location" class="col-4 col-sm-3 col-form-label">{{ form.location.label }}<span class="text-danger"><b>*</b></span></label>
<div class="col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.location.errors %}has-danger{% endif %}">
@ -69,8 +76,14 @@
</div>
</div>
<div class="form-group row ">
<label for="id_information" class="col-4 col-sm-3 col-form-label">Informations</label>
<div class="col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.id_informations.errors %}has-danger{% endif %}">
<label for="id_diagnosis" class="col-4 col-sm-3 col-form-label">{{ form.diagnosis.label }}</label>
<div class="col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.id_diagnosis.errors %}has-danger{% endif %}">
{{ form.diagnosis }}
</div>
</div>
<div class="form-group row ">
<label for="id_informations" class="col-4 col-sm-3 col-form-label">Commentaires</label>
<div class="col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.informations.errors %}has-danger{% endif %}">
{{ form.informations }}
</div>
</div>

View File

@ -6,32 +6,79 @@
<div class="col-12 col-sm-8 col-md-6">
<div class="card">
<div class="card-header">
<h4 class="card-title mb-0">Well being {{ wellbeing.date | date:"d N Y" }}</h4>
<h4 class="card-title mb-0"><a href="{% url 'gymnast_details_tab' wellbeing.gymnast.id 'physiological' %}">{{ wellbeing.gymnast }}</a>'s well being on {{ wellbeing.date | date:"j F Y" }}</h4>
</div>
<div class="card-body">
<a href="{% url 'gymnast_details_tab' wellbeing.gymnast.id 'physiological' %}">{{ wellbeing.gymnast }}</a><br />
Mindstate : {{ wellbeing.mindstate }}<br />
Sleep : {{ wellbeing.sleep }}<br />
Stress : {{ wellbeing.stress }}<br />
Fatigue : {{ wellbeing.fatigue }}<br />
Muscle soreness : {{ wellbeing.muscle_soreness }}<br />
<br />
<div class="card-body text-center">
{% if wellbeing.to_markdown %}
{{ wellbeing.to_markdown | safe }}
{% else %}
<p class="text-muted">No additionnal details.</p>
{% endif %}
<div class="card-footer pl-0 pb-0">
<a href="{% url 'wellbeing_list' %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="tim-icons icon-double-left"></i>
</button>
</a>
</div>
<canvas id="chart_radar_wellbeing" class="chartjs" width="400" height="400"></canvas>
<p class="text-muted">Mindstate : {{ wellbeing.mindstate }}&nbsp;&nbsp;|&nbsp;&nbsp;Sleep : {{ wellbeing.sleep }}&nbsp;&nbsp;|&nbsp;&nbsp;Stress : {{ wellbeing.stress }}&nbsp;&nbsp;|&nbsp;&nbsp;Fatigue : {{ wellbeing.fatigue }}&nbsp;&nbsp;|&nbsp;&nbsp;Muscle soreness : {{ wellbeing.muscle_soreness }}</p>
</div>
<div class="card-footer">
<a href="{% url 'wellbeing_list' %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="tim-icons icon-double-left"></i>
</button>
</a>
</div>
</div>
</div>
</div>
{% endblock %}
{% block footerscript %}
<script type="text/javascript">
var ctx = document.getElementById("chart_radar_wellbeing").getContext("2d");
const data = {
labels: [
'Mind State',
'Sleep',
'Zen',
'Rest',
'Muscle',
],
datasets: [{
data: [{{ wellbeing.mindstate }}, {{ wellbeing.sleep }}, {{ wellbeing.get_inversed_stress }}, {{ wellbeing.get_inversed_fatigue }}, {{ wellbeing.get_inversed_muscle_soreness }}],
fill: true,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgb(255, 99, 132)',
pointBackgroundColor: 'rgb(255, 99, 132)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(255, 99, 132)'
}]
};
new Chart(ctx, {
responsive: true,
type: 'radar',
data: data,
options: {
elements: {
line: {
borderWidth: 3
}
},
scales: {
r: {
// angleLines: {
// display: false
// },
suggestedMin: 0,
suggestedMax: 10,
}
},
plugins: {
legend: {
display: false,
}
}
},
});
</script>
{% endblock %}

View File

@ -45,12 +45,34 @@
</a>
</td>
<td class="text-left"><a href="{% url 'wellbeing_details' wellbeing.id %}">{{ wellbeing.date | date:"d-m-Y" }}</a></td>
<td class="text-left"><a href="{% url 'gymnast_details_tab' wellbeing.gymnast.id 'physiological' %}">{{ wellbeing.gymnast }}</a></td>
<td class="text-right">{{ wellbeing.mindstate }}</td>
<td class="text-right">{{ wellbeing.sleep }}</td>
<td class="text-right">{{ wellbeing.stress }}</td>
<td class="text-right">{{ wellbeing.fatigue }}</td>
<td class="text-right">{{ wellbeing.muscle_soreness }}</td>
<td class="text-left">
<a href="{% url 'gymnast_details_tab' wellbeing.gymnast.id 'physiological' %}">
{{ wellbeing.gymnast }}</td>
<td class="text-right">
{% if wellbeing.mindstate < 5%}<b><span class="text-danger">{% endif %}
{{ wellbeing.mindstate }}
{% if wellbeing.mindstate < 5%}</b></span>{% endif %}
</td>
<td class="text-right">
{% if wellbeing.sleep < 5%}<b><span class="text-danger">{% endif %}
{{ wellbeing.sleep }}
{% if wellbeing.sleep < 5%}</b></span>{% endif %}
</td>
<td class="text-right">
{% if wellbeing.stress < 5%}<b><span class="text-danger">{% endif %}
{{ wellbeing.stress }}
{% if wellbeing.stress < 5%}</b></span>{% endif %}
</td>
<td class="text-right">
{% if wellbeing.fatigue < 5%}<b><span class="text-danger">{% endif %}
{{ wellbeing.fatigue }}
{% if wellbeing.fatigue < 5%}</b></span>{% endif %}
</td>
<td class="text-right">
{% if wellbeing.muscle_soreness < 5%}<b><span class="text-danger">{% endif %}
{{ wellbeing.muscle_soreness }}
{% if wellbeing.muscle_soreness < 5%}</b></span>{% endif %}
</td>
</tr>
{% endfor %}
</tbody>

View File

@ -976,6 +976,7 @@ def wellbeing_create_or_update(
<li>Stress: {stress}</li>
<li>Fatigue: {fatigue}</li>
<li>Muscle_soreness: {muscle_soreness}</li>
</ul>
</p><br />
<p>Excellente journée</p><p>Jarvis</p>""",
)

View File

@ -74,6 +74,7 @@
<th style="width: 3%"></th>
<th class="header text-center" style="width: 10%">Date</th>
<th class="header text-left" style="width: 10%">Mechanism</th>
<th class="header text-left" style="width: 10%">Type</th>
<th class="header text-left" style="width: 25%">Location</th>
<th class="header text-left" style="width: 10%">Side</th>
<th class="header text-left" style="width: 15%">Skill</th>
@ -90,6 +91,7 @@
</td>
<td class="text-center"><a href="{% url 'injury_details' injury.id %}">{{ injury.date | date:"d-m-Y" }}</a></td>
<td class="text-left">{{ injury.get_mechanism_display }}</td>
<td class="text-left">{{ injury.type }}</td>
<td class="text-left">{{ injury.location }}</td>
<td class="text-left">{{ injury.get_body_side_display }}</td>
<td class="text-left">{% if injury.skill %}<a href="{% url 'skill_details' injury.skill.id %}">{{ injury.skill.notation }}</a>{% else %}-{% endif %}</td>

View File

@ -38,13 +38,13 @@
<div class="col-md-6 pl-1">
<div class="card">
<div class="card-header">
<h4>Chrono</h4>
<h4>Chronos</h4>
</div>
<div class="card-body pt-0 pb-0 pr-0 pl-0">
{% if chrono_list %}
<div><canvas id="chart_chrono" class="chartjs" width="400" height="200"></canvas></div>
{% else %}
<p class="pl-3 text-muted">No chrono recorded for this gymnast.</p>
<p class="pl-3 text-muted">No chrono recorded yet for this gymnast.</p>
{% endif %}
</div>
<div class="card-footer pt-0 row">