From c910374a1bb5fd6b33b2613d82fc77b65d3f95fc Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Thu, 9 May 2024 20:38:23 +0100 Subject: [PATCH] Update gymnast dashboard --- .../core/templates/dashboard/dashboard.html | 18 +++++++++-- jarvis/core/views.py | 31 +++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/jarvis/core/templates/dashboard/dashboard.html b/jarvis/core/templates/dashboard/dashboard.html index db8a3ef..0fe1f16 100644 --- a/jarvis/core/templates/dashboard/dashboard.html +++ b/jarvis/core/templates/dashboard/dashboard.html @@ -106,8 +106,8 @@
- {% if is_trainer %}
+ {% if is_trainer %}

Updated needed

@@ -125,8 +125,22 @@ No update needed. {% endif %}
+ {% else %} +
+

Your last profile update

+
+
+
    +
  1. Wellbeing: {{ wellbeing_last_update.0 |date:"j F Y" }}
  2. +
  3. Height/Weight: {{ height_weight_last_update.0 |date:"j F Y" }}
  4. +
  5. Intensity: {{ intensities_last_update.0 |date:"j F Y" }}
  6. + +
  7. Chrono: {{ chronos_last_update.0 |date:"j F Y" }}
  8. +
  9. Learned Skill: {{ known_skills_last_update.0 |date:"j F Y" }}
  10. +
+
+ {% endif %}
- {% endif %}
diff --git a/jarvis/core/views.py b/jarvis/core/views.py index 9ff39a3..0bbdce2 100644 --- a/jarvis/core/views.py +++ b/jarvis/core/views.py @@ -5,7 +5,7 @@ import pendulum from django.db.models import Max from django.conf import settings from django.db.models import Q, F, OuterRef, Subquery -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 from django.utils import timezone from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout from django.http import HttpResponse, HttpResponseRedirect @@ -17,7 +17,15 @@ from django.contrib.auth import get_user_model from jarvis.objective.models import Routine from jarvis.profiles.models import Profile -from jarvis.followup.models import Skill, Point, Chrono +from jarvis.followup.models import ( + Skill, + Point, + Chrono, + WellBeing, + Intensity, + HeightWeight, + LearnedSkill +) from jarvis.location.models import Place, Club from jarvis.people.models import Gymnast from jarvis.people.views import gymnast_details @@ -142,9 +150,22 @@ def home(request): ) .distinct() ) + wellbeing_last_update = None + height_weight_last_update = None + intensities_last_update = None + # points_last_update = None + chronos_last_update = None + # known_skills_last_update = None else: + gymnast = get_object_or_404(Gymnast, pk=request.user.gymnast.id) last_updated_gymnasts = None waiting_update_gymnast = None + wellbeing_last_update = WellBeing.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first() + height_weight_last_update = HeightWeight.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first() + intensities_last_update = Intensity.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first() + # points_last_update = Gymnast.objects.all().order_by("-date")[:1] + chronos_last_update = Chrono.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first() + known_skills_last_update = LearnedSkill.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first() # TODO: véririer si c'est l'anniversaire de la personne qui est connectée. @@ -186,6 +207,12 @@ def home(request): "nb_routine": nb_routine, "nb_score": nb_score, "nb_club": nb_club, + "wellbeing_last_update": wellbeing_last_update, + "height_weight_last_update": height_weight_last_update, + "intensities_last_update": intensities_last_update, + # "points_last_update": points_last_update, + "chronos_last_update": chronos_last_update, + "known_skills_last_update": known_skills_last_update, "percentage_week": percentage_week, "birthday_list": birthday_list, "is_trainer": is_trainer,