Update gymnast dashboard

This commit is contained in:
Gregory Trullemans 2024-05-09 20:38:23 +01:00
parent 4ec24b630d
commit c910374a1b
2 changed files with 45 additions and 4 deletions

View File

@ -106,8 +106,8 @@
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
{% if is_trainer %}
<div class="card"> <div class="card">
{% if is_trainer %}
<div class="card-header"> <div class="card-header">
<h4><i class="fal fa-exclamation-triangle text-danger"></i> Updated needed</h4> <h4><i class="fal fa-exclamation-triangle text-danger"></i> Updated needed</h4>
</div> </div>
@ -125,9 +125,23 @@
No update needed. No update needed.
{% endif %} {% endif %}
</div> </div>
{% else %}
<div class="card-header">
<h4><i class="fal fa-exclamation-triangle text-danger"></i> Your last profile update</h4>
</div>
<div class="card-body pt-0">
<ol class="list-unstyled">
<li>Wellbeing: <i>{{ wellbeing_last_update.0 |date:"j F Y" }}</i></li>
<li>Height/Weight: <i>{{ height_weight_last_update.0 |date:"j F Y" }}</i></li>
<li>Intensity: <i>{{ intensities_last_update.0 |date:"j F Y" }}</i></li>
<!-- <li>{{ points_last_update }}</li> -->
<li>Chrono: <i>{{ chronos_last_update.0 |date:"j F Y" }}</i></li>
<li>Learned Skill: <i>{{ known_skills_last_update.0 |date:"j F Y" }}</i></li>
</ol>
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div>
<div class="col-md-3"> <div class="col-md-3">
{% if is_trainer %} {% if is_trainer %}

View File

@ -5,7 +5,7 @@ import pendulum
from django.db.models import Max from django.db.models import Max
from django.conf import settings from django.conf import settings
from django.db.models import Q, F, OuterRef, Subquery 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.utils import timezone
from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout
from django.http import HttpResponse, HttpResponseRedirect 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.objective.models import Routine
from jarvis.profiles.models import Profile 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.location.models import Place, Club
from jarvis.people.models import Gymnast from jarvis.people.models import Gymnast
from jarvis.people.views import gymnast_details from jarvis.people.views import gymnast_details
@ -142,9 +150,22 @@ def home(request):
) )
.distinct() .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: else:
gymnast = get_object_or_404(Gymnast, pk=request.user.gymnast.id)
last_updated_gymnasts = None last_updated_gymnasts = None
waiting_update_gymnast = 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. # 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_routine": nb_routine,
"nb_score": nb_score, "nb_score": nb_score,
"nb_club": nb_club, "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, "percentage_week": percentage_week,
"birthday_list": birthday_list, "birthday_list": birthday_list,
"is_trainer": is_trainer, "is_trainer": is_trainer,