From 0a42d3febf7d609aedd07d82bc454e206f06f374 Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Wed, 11 Oct 2023 12:12:01 +0200 Subject: [PATCH] Update wellbeing listing --- jarvis/followup/admin.py | 10 +++ jarvis/followup/forms.py | 4 +- jarvis/followup/models.py | 36 +++++++++ .../followup/templates/injuries/create.html | 17 +++- .../followup/templates/wellbeing/details.html | 79 +++++++++++++++---- jarvis/followup/templates/wellbeing/list.html | 34 ++++++-- jarvis/followup/views.py | 1 + .../gymnasts/tabs/tab_physiological.html | 2 + .../gymnasts/tabs/tab_scores_and_chronos.html | 4 +- 9 files changed, 160 insertions(+), 27 deletions(-) diff --git a/jarvis/followup/admin.py b/jarvis/followup/admin.py index ff48c1c..5487722 100644 --- a/jarvis/followup/admin.py +++ b/jarvis/followup/admin.py @@ -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) diff --git a/jarvis/followup/forms.py b/jarvis/followup/forms.py index 6c2ae8b..a4c8393 100644 --- a/jarvis/followup/forms.py +++ b/jarvis/followup/forms.py @@ -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 } ), } diff --git a/jarvis/followup/models.py b/jarvis/followup/models.py index a40178e..ff27f4c 100644 --- a/jarvis/followup/models.py +++ b/jarvis/followup/models.py @@ -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): """ diff --git a/jarvis/followup/templates/injuries/create.html b/jarvis/followup/templates/injuries/create.html index c22c50e..a6750e3 100644 --- a/jarvis/followup/templates/injuries/create.html +++ b/jarvis/followup/templates/injuries/create.html @@ -47,6 +47,13 @@ {% if form.mechanism.errors %} {% for error in form.mechanism.errors %}{{ error }}{% endfor %}{% endif %} +
+ +
+ {{ form.injury_type }} + {% if form.injury_type.errors %} {% for error in form.injury_type.errors %}{{ error }}{% endfor %}{% endif %} +
+
@@ -69,8 +76,14 @@
- -
+ +
+ {{ form.diagnosis }} +
+
+
+ +
{{ form.informations }}
diff --git a/jarvis/followup/templates/wellbeing/details.html b/jarvis/followup/templates/wellbeing/details.html index ce93128..527f22c 100644 --- a/jarvis/followup/templates/wellbeing/details.html +++ b/jarvis/followup/templates/wellbeing/details.html @@ -6,32 +6,79 @@
-

Well being {{ wellbeing.date | date:"d N Y" }}

+

{{ wellbeing.gymnast }}'s well being on {{ wellbeing.date | date:"j F Y" }}

-
- {{ wellbeing.gymnast }}
- Mindstate : {{ wellbeing.mindstate }}
- Sleep : {{ wellbeing.sleep }}
- Stress : {{ wellbeing.stress }}
- Fatigue : {{ wellbeing.fatigue }}
- Muscle soreness : {{ wellbeing.muscle_soreness }}
-
+
{% if wellbeing.to_markdown %} {{ wellbeing.to_markdown | safe }} {% else %}

No additionnal details.

{% endif %} - + +

Mindstate : {{ wellbeing.mindstate }}  |  Sleep : {{ wellbeing.sleep }}  |  Stress : {{ wellbeing.stress }}  |  Fatigue : {{ wellbeing.fatigue }}  |  Muscle soreness : {{ wellbeing.muscle_soreness }}

+
+
+{% endblock %} +{% block footerscript %} + {% endblock %} \ No newline at end of file diff --git a/jarvis/followup/templates/wellbeing/list.html b/jarvis/followup/templates/wellbeing/list.html index d6f0af2..ace8d97 100644 --- a/jarvis/followup/templates/wellbeing/list.html +++ b/jarvis/followup/templates/wellbeing/list.html @@ -45,12 +45,34 @@ {{ wellbeing.date | date:"d-m-Y" }} - {{ wellbeing.gymnast }} - {{ wellbeing.mindstate }} - {{ wellbeing.sleep }} - {{ wellbeing.stress }} - {{ wellbeing.fatigue }} - {{ wellbeing.muscle_soreness }} + + + {{ wellbeing.gymnast }} + + {% if wellbeing.mindstate < 5%}{% endif %} + {{ wellbeing.mindstate }} + {% if wellbeing.mindstate < 5%}{% endif %} + + + {% if wellbeing.sleep < 5%}{% endif %} + {{ wellbeing.sleep }} + {% if wellbeing.sleep < 5%}{% endif %} + + + {% if wellbeing.stress < 5%}{% endif %} + {{ wellbeing.stress }} + {% if wellbeing.stress < 5%}{% endif %} + + + {% if wellbeing.fatigue < 5%}{% endif %} + {{ wellbeing.fatigue }} + {% if wellbeing.fatigue < 5%}{% endif %} + + + {% if wellbeing.muscle_soreness < 5%}{% endif %} + {{ wellbeing.muscle_soreness }} + {% if wellbeing.muscle_soreness < 5%}{% endif %} + {% endfor %} diff --git a/jarvis/followup/views.py b/jarvis/followup/views.py index c875c0c..a9e18b1 100644 --- a/jarvis/followup/views.py +++ b/jarvis/followup/views.py @@ -976,6 +976,7 @@ def wellbeing_create_or_update(
  • Stress: {stress}
  • Fatigue: {fatigue}
  • Muscle_soreness: {muscle_soreness}
  • +


    Excellente journée

    Jarvis

    """, ) diff --git a/jarvis/people/templates/gymnasts/tabs/tab_physiological.html b/jarvis/people/templates/gymnasts/tabs/tab_physiological.html index 4f05737..234382f 100644 --- a/jarvis/people/templates/gymnasts/tabs/tab_physiological.html +++ b/jarvis/people/templates/gymnasts/tabs/tab_physiological.html @@ -74,6 +74,7 @@ Date Mechanism + Type Location Side Skill @@ -90,6 +91,7 @@
    {{ injury.date | date:"d-m-Y" }} {{ injury.get_mechanism_display }} + {{ injury.type }} {{ injury.location }} {{ injury.get_body_side_display }} {% if injury.skill %}{{ injury.skill.notation }}{% else %}-{% endif %} diff --git a/jarvis/people/templates/gymnasts/tabs/tab_scores_and_chronos.html b/jarvis/people/templates/gymnasts/tabs/tab_scores_and_chronos.html index a6f3f42..f2e05d5 100644 --- a/jarvis/people/templates/gymnasts/tabs/tab_scores_and_chronos.html +++ b/jarvis/people/templates/gymnasts/tabs/tab_scores_and_chronos.html @@ -38,13 +38,13 @@
    -

    Chrono

    +

    Chronos

    {% if chrono_list %}
    {% else %} -

    No chrono recorded for this gymnast.

    +

    No chrono recorded yet for this gymnast.

    {% endif %}