Minor modificatin

This commit is contained in:
Gregory Trullemans 2023-07-10 10:38:28 +02:00
parent 87a5c57128
commit ae7153565c
13 changed files with 116 additions and 36 deletions

View File

@ -112,14 +112,21 @@ class InjuryAdmin(admin.ModelAdmin):
"mechanism", "mechanism",
"nb_week_off", "nb_week_off",
"informations", "informations",
) # educative )
readonly_fields = ("season", "week_number", "created_at", "updated_at") readonly_fields = ("season", "week_number", "created_at", "updated_at")
list_display = ("date", "gymnast", "skill") # educative list_display = (
"date",
"gymnast",
"mechanism",
"location",
"body_side",
"nb_week_off",
)
list_filter = ( list_filter = (
("gymnast", RelatedDropdownFilter), ("gymnast", RelatedDropdownFilter),
("mechanism", DropdownFilter),
("location", RelatedDropdownFilter), ("location", RelatedDropdownFilter),
("body_side", DropdownFilter), ("body_side", DropdownFilter),
("mechanism", DropdownFilter),
) )
date_hierarchy = "date" date_hierarchy = "date"
search_fields = ("date", "gymnast") # educative search_fields = ("date", "gymnast") # educative

View File

@ -191,6 +191,7 @@ class InjuryForm(forms.ModelForm):
"location", "location",
"body_side", "body_side",
"nb_week_off", "nb_week_off",
"diagnosis",
"informations", "informations",
) )
widgets = { widgets = {
@ -209,10 +210,16 @@ class InjuryForm(forms.ModelForm):
"nb_week_off": forms.NumberInput( "nb_week_off": forms.NumberInput(
attrs={"class": "form-control", "placeholder": "xx"} attrs={"class": "form-control", "placeholder": "xx"}
), ),
"diagnosis": forms.Textarea(
attrs={
"class": "form-control",
"placeholder": "Informations about diagnosis", # pylint: disable=line-too-long
}
),
"informations": forms.Textarea( "informations": forms.Textarea(
attrs={ attrs={
"class": "form-control", "class": "form-control",
"placeholder": "Informations about injury: context (why, where, …), consequencies, re-education exercices, …", # pylint: disable=line-too-long "placeholder": "Informations about injury: consequencies, re-education exercices, …", # pylint: disable=line-too-long
} }
), ),
} }

View File

@ -15,7 +15,6 @@ class Migration(migrations.Migration):
model_name="injury", model_name="injury",
name="location", name="location",
field=models.ForeignKey( field=models.ForeignKey(
# default=1,
on_delete=django.db.models.deletion.CASCADE, on_delete=django.db.models.deletion.CASCADE,
related_name="injuries", related_name="injuries",
to="followup.injurylocation", to="followup.injurylocation",
@ -24,6 +23,5 @@ class Migration(migrations.Migration):
null=True, null=True,
blank=True, blank=True,
), ),
# preserve_default=False,
), ),
] ]

View File

@ -0,0 +1,24 @@
# Generated by Django 4.2 on 2023-07-08 17:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("followup", "0055_alter_injury_body_side"),
]
operations = [
migrations.AlterField(
model_name="injury",
name="location",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="injuries",
to="followup.injurylocation",
verbose_name="Location",
),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2 on 2023-07-08 18:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("followup", "0056_alter_injury_location"),
]
operations = [
migrations.AddField(
model_name="injury",
name="diagnosis",
field=models.TextField(
blank=True,
help_text="Only normal text is authorized",
null=True,
verbose_name="Diagnosis",
),
),
]

View File

@ -199,6 +199,12 @@ class Injury(Markdownizable, Seasonisable):
mechanism = models.PositiveSmallIntegerField( mechanism = models.PositiveSmallIntegerField(
choices=INJURY_MECHANISM_CHOICE, verbose_name="Injury mechanism" choices=INJURY_MECHANISM_CHOICE, verbose_name="Injury mechanism"
) )
diagnosis = models.TextField(
null=True,
blank=True,
verbose_name="Diagnosis",
help_text="Only normal text is authorized",
)
nb_week_off = models.SmallIntegerField( nb_week_off = models.SmallIntegerField(
blank=True, null=True, verbose_name="# week off" blank=True, null=True, verbose_name="# week off"
) )
@ -206,10 +212,10 @@ class Injury(Markdownizable, Seasonisable):
updated_at = models.DateTimeField(auto_now=True) updated_at = models.DateTimeField(auto_now=True)
def __str__(self): def __str__(self):
return f"{self.gymnast} ({self.date})" return f"{self.gymnast} ({self.date}): {self.mechanism} on {self.location} {self.body_side}"
def timeline_representation(self): def timeline_representation(self):
return f"<li>{self.date:%d %b %Y} - Accident ({self.skill}): {self.nb_week_off} (weeks off)</li>" return f"<li>{self.date:%d %b %Y} - Injury ({self.skill}): {self.nb_week_off} (weeks off)</li>"
class LearnedSkill(Seasonisable): class LearnedSkill(Seasonisable):

View File

@ -7,7 +7,7 @@
<div class="col-12 col-sm-12 col-md-8 col-lg-6 col-xl-6"> <div class="col-12 col-sm-12 col-md-8 col-lg-6 col-xl-6">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="">{% if heightweight_id %}Edit{% else %}Add{% endif %} height/weight couple</h4> <h4 class="">{% if heightweight_id %}Edit{% else %}Add{% endif %} height & weight</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
{% if form.errors %} {% if form.errors %}

View File

@ -7,7 +7,7 @@
<div class="card"> <div class="card">
<div class="card-header row"> <div class="card-header row">
<div class="col-8"> <div class="col-8">
<h4 class="">Height/Weight list {% if gymnast %}for <a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}"><i>{{ gymnast }}</i></a>{% endif %}</h4> <h4 class="">Height & Weight list {% if gymnast %}for <a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}"><i>{{ gymnast }}</i></a>{% endif %}</h4>
</div> </div>
<div class="col-1 ml-auto"> <div class="col-1 ml-auto">
<div class="text-right"> <div class="text-right">

View File

@ -30,7 +30,7 @@
<th class="header text-left" style="width: 9%">Mechanism</th> <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: 20%">Location</th>
<th class="header text-left" style="width: 8%">Side</th> <th class="header text-left" style="width: 8%">Side</th>
<th style="width: 20%">Skill</th> <th style="width: 12%">Skill</th>
<th style="width: 8%"># Week off</th> <th style="width: 8%"># Week off</th>
</tr> </tr>
</thead> </thead>
@ -49,7 +49,7 @@
<td class="text-left">{{ injury.get_body_side_display }}</td> <td class="text-left">{{ injury.get_body_side_display }}</td>
<td class="text-left"> <td class="text-left">
{% if injury.skill %} {% if injury.skill %}
<a href="{% url 'skill_details' injury.skill.id %}">{{ injury.skill }}</a> <a href="{% url 'skill_details' injury.skill.id %}">{{ injury.skill.notation }}</a>
{% else %} {% else %}
- -
{% endif %} {% endif %}

View File

@ -54,8 +54,8 @@
{{ form.mindstate }} {{ form.mindstate }}
{% if form.mindstate.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.mindstate.errors %}{{ error }}{% endfor %}</span>{% endif %} {% if form.mindstate.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.mindstate.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div> </div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5"> <div class="col-4 col-sm-3 col-md-5 c ol-lg-5">
<p class="text-muted">(1: Very Bad - 10: Very Good)</p> <h3 class="card-category text-muted">(1: Very Bad - 10: Very Good)</h3>
</div> </div>
</div> </div>
<div class="form-group row "> <div class="form-group row ">
@ -65,7 +65,7 @@
{% if form.sleep.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.sleep.errors %}{{ error }}{% endfor %}</span>{% endif %} {% if form.sleep.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.sleep.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div> </div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5"> <div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Bad - 10: Very Good)</p> <h3 class="card-category text-muted">(1: Very Bad - 10: Very Good)</h3>
</div> </div>
</div> </div>
<div class="form-group row "> <div class="form-group row ">
@ -75,7 +75,7 @@
{% if form.stress.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.stress.errors %}{{ error }}{% endfor %}</span>{% endif %} {% if form.stress.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.stress.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div> </div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5"> <div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Low - 10: Very High)</p> <h3 class="card-category text-muted">(1: Very Low - 10: Very High)</h3>
</div> </div>
</div> </div>
<div class="form-group row "> <div class="form-group row ">
@ -85,7 +85,7 @@
{% if form.fatigue.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.fatigue.errors %}{{ error }}{% endfor %}</span>{% endif %} {% if form.fatigue.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.fatigue.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div> </div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5"> <div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Low - 10: Very High)</p> <h3 class="card-category text-muted">(1: Very Low - 10: Very High)</h3>
</div> </div>
</div> </div>
<div class="form-group row "> <div class="form-group row ">
@ -95,7 +95,7 @@
{% if form.muscle_soreness.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.muscle_soreness.errors %}{{ error }}{% endfor %}</span>{% endif %} {% if form.muscle_soreness.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.muscle_soreness.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div> </div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5"> <div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Low - 10: Very High)</p> <h3 class="card-category text-muted">(1: Very Low - 10: Very High)</h3>
</div> </div>
</div> </div>
<div class="form-group row "> <div class="form-group row ">

View File

@ -1470,9 +1470,7 @@ def season_information_create_or_update(
) )
) )
else: else:
return render( return render(request, "seasoninformations/create.html", {"form": form})
request, "followup/seasoninformations/create.html", {"form": form}
)
form = SeasonInformationForm(instance=season_information, initial=data) form = SeasonInformationForm(instance=season_information, initial=data)
context = {"form": form, "season_information_id": season_information_id} context = {"form": form, "season_information_id": season_information_id}

View File

@ -25,7 +25,7 @@
</a> </a>
<p class="description"> <p class="description">
{{ last_season_information.club.name }}<br /> {{ last_season_information.club.name }}<br />
<b>{{ last_season_information.get_category_display }}</b> <b>{{ gymnast.birthdate.year }} - {{ last_season_information.get_category_display }}</b>
</p> </p>
</div> </div>
<div class="card-description"> <div class="card-description">
@ -35,7 +35,8 @@
{% if height_weight %} {% if height_weight %}
<b>{{ height_weight.0.height }}cm - {{ height_weight.0.weight }}kg</b> ({{ height_weight.0.date | date:"d-m-Y" }})<br /> <b>{{ height_weight.0.height }}cm - {{ height_weight.0.weight }}kg</b> ({{ height_weight.0.date | date:"d-m-Y" }})<br />
{% endif %} {% endif %}
<b>{{ last_season_information.number_of_training_sessions_per_week }} training/week</b> for <b>{{ last_season_information.number_of_hours_per_week }} hours/week</b><br /> Training: <b>{{ last_season_information.number_of_training_sessions_per_week }}/week</b> ({{ last_season_information.number_of_hours_per_week }} hours)<br />
S&C: <b>{{ last_season_information.number_of_s_and_c_sessions_per_week }}/week</b>({{ last_season_information.number_of_s_and_c_hours_per_week }} hours)<br />
<br /> <br />
{% if user_is_trainer and gymnast.informations %} {% if user_is_trainer and gymnast.informations %}
<p>{{ gymnast.to_markdown | safe }}</p> <p>{{ gymnast.to_markdown | safe }}</p>
@ -45,7 +46,7 @@
<b>10 |</b> : {% if best_straightjump %}<b>{{ best_straightjump.0.tof }}</b> ({{ best_straightjump.0.date | date:"d-m-Y" }}){% else %} <span class="text-muted">(no information)</span>{% endif %} <b>10 |</b> : {% if best_straightjump %}<b>{{ best_straightjump.0.tof }}</b> ({{ best_straightjump.0.date | date:"d-m-Y" }}){% else %} <span class="text-muted">(no information)</span>{% endif %}
</li> </li>
<li> <li>
<b>Routine</b> : {% if best_routine %}<b>{{ best_routine.0.tof }}</b> ({{ best_routine.0.date | date:"d-m-Y" }}){% else %} <span class="text-muted">(no information)</span>{% endif %} <b>Q1R1</b> : {% if best_routine %}<b>{{ best_routine.0.tof }}</b> ({{ best_routine.0.date | date:"d-m-Y" }}){% else %} <span class="text-muted">(no information)</span>{% endif %}
</li> </li>
{% if user_is_trainer %} {% if user_is_trainer %}
<a href="{% url 'add_season_information_for_gymnast' gymnast.id %}">Add season details</a> - <a href="{% url 'add_season_information_for_gymnast' gymnast.id %}">Add season details</a> -

View File

@ -3,7 +3,7 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-header"> <div class="card-header">
<h4>Height/Weight</h4> <h4>Height & Weight</h4>
</div> </div>
<div class="card-body pt-0 pb-0 pr-0 pl-0"> <div class="card-body pt-0 pb-0 pr-0 pl-0">
{% if height_weight_list %} {% if height_weight_list %}
@ -76,7 +76,7 @@
<th class="header text-left" style="width: 10%">Mechanism</th> <th class="header text-left" style="width: 10%">Mechanism</th>
<th class="header text-left" style="width: 25%">Location</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: 10%">Side</th>
<th class="header text-left" style="width: 25%">Skill</th> <th class="header text-left" style="width: 15%">Skill</th>
<th class="header text-center" style="width: 10%"># Week Off</th> <th class="header text-center" style="width: 10%"># Week Off</th>
</tr> </tr>
</thead> </thead>
@ -92,7 +92,7 @@
<td class="text-left">{{ injury.get_mechanism_display }}</td> <td class="text-left">{{ injury.get_mechanism_display }}</td>
<td class="text-left">{{ injury.location }}</td> <td class="text-left">{{ injury.location }}</td>
<td class="text-left">{{ injury.get_body_side_display }}</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 }}</a>{% else %}-{% endif %}</td> <td class="text-left">{% if injury.skill %}<a href="{% url 'skill_details' injury.skill.id %}">{{ injury.skill.notation }}</a>{% else %}-{% endif %}</td>
<td class="text-center">{{ injury.nb_week_off }}</td> <td class="text-center">{{ injury.nb_week_off }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -234,12 +234,19 @@
gradient_stroke_green.addColorStop(0.5, 'rgba(75, 192, 192, 0.2)'); gradient_stroke_green.addColorStop(0.5, 'rgba(75, 192, 192, 0.2)');
gradient_stroke_green.addColorStop(0.25, 'rgba(75, 192, 192, 0)'); gradient_stroke_green.addColorStop(0.25, 'rgba(75, 192, 192, 0)');
var border_color_4 = 'rgb(54, 162, 235)'; var border_color_blue = 'rgb(54, 162, 235)';
var gradient_stroke_4 = ctx.createLinearGradient(0, 230, 0, 50); var gradient_stroke_blue = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_4.addColorStop(1, 'rgba(54, 162, 235, 0.4)'); gradient_stroke_blue.addColorStop(1, 'rgba(54, 162, 235, 0.4)');
gradient_stroke_4.addColorStop(0.75, 'rgba(54, 162, 235, 0.3)'); gradient_stroke_blue.addColorStop(0.75, 'rgba(54, 162, 235, 0.3)');
gradient_stroke_4.addColorStop(0.5, 'rgba(54, 162, 235, 0.2)'); gradient_stroke_blue.addColorStop(0.5, 'rgba(54, 162, 235, 0.2)');
gradient_stroke_4.addColorStop(0.25, 'rgba(54, 162, 235, 0)'); gradient_stroke_blue.addColorStop(0.25, 'rgba(54, 162, 235, 0)');
var border_color_yellow = 'rgb(255, 205, 86)';
var gradient_stroke_yellow = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_yellow.addColorStop(1, 'rgba(255, 205, 86, 0.4)');
gradient_stroke_yellow.addColorStop(0.75, 'rgba(255, 205, 86, 0.3)');
gradient_stroke_yellow.addColorStop(0.5, 'rgba(255, 205, 86, 0.2)');
gradient_stroke_yellow.addColorStop(0.25, 'rgba(255, 205, 86, 0)');
var mindstate_values = [ var mindstate_values = [
{% for wellbeing in wellbeing_list %} {% for wellbeing in wellbeing_list %}
@ -318,12 +325,21 @@
{ {
label: 'Fatigue', label: 'Fatigue',
cubicInterpolationMode: 'monotone', cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_4, backgroundColor: gradient_stroke_blue,
borderColor: border_color_4, borderColor: border_color_blue,
pointBackgroundColor: border_color_4, pointBackgroundColor: border_color_blue,
fill: true, fill: true,
data: fatigue_values, data: fatigue_values,
}, },
{
label: 'Muscle',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_yellow,
borderColor: border_color_yellow,
pointBackgroundColor: border_color_yellow,
fill: true,
data: muscle_soreness_values,
},
], ],
}; };