Compare commits

...

3 Commits

Author SHA1 Message Date
Gregory Trullemans 99cd1d01e6 Bug fix 2024-05-14 10:06:31 +02:00
Gregory Trullemans 5e3b4222cd Update dashboard 2024-05-13 14:18:22 +02:00
Gregory Trullemans 2827ca9669 Bug fix 2024-05-13 14:13:38 +02:00
4 changed files with 71 additions and 47 deletions

View File

@ -136,7 +136,11 @@
{% if wellbeing_state %}
<span class="text-{{ wellbeing_state }}">
{% endif %}
{% if wellbeing_last_record_date %}
{{ wellbeing_last_record_date.0 |date:"j F Y" }}
{% else %}
Never
{% endif %}
{% if wellbeing_state %}
</span>
{% endif %}
@ -146,7 +150,11 @@
{% if height_weight_state %}
<span class="text-{{ height_weight_state }}">
{% endif %}
{% if height_weight_last_record_date %}
{{ height_weight_last_record_date.0 |date:"j F Y" }}
{% else %}
Never
{% endif %}
{% if wellbeing_state %}
</span>
{% endif %}
@ -156,7 +164,11 @@
{% if intensity_state %}
<span class="text-{{ intensity_state }}">
{% endif %}
{% if intensities_last_record_date %}
{{ intensities_last_record_date.0 |date:"j F Y" }}
{% else %}
Never
{% endif %}
{% if wellbeing_state %}
</span>
{% endif %}
@ -167,7 +179,11 @@
{% if chrono_state %}
<span class="text-{{ chrono_state }}">
{% endif %}
{% if chrono_last_record_date %}
{{ chrono_last_record_date.0 |date:"j F Y" }}
{% else %}
Never
{% endif %}
{% if chrono_state %}
</span>
{% endif %}
@ -177,7 +193,11 @@
{% if known_skills_state %}
<span class="text-{{ known_skills_state }}">
{% endif %}
{% if known_skills_last_record_date %}
{{ known_skills_last_record_date.0 |date:"j F Y" }}
{% else %}
Never
{% endif %}
{% if known_skills_state %}
</span>
{% endif %}

View File

@ -201,56 +201,56 @@ def home(request):
# print("Pas son annif…")
wellbeing_last_record_date = WellBeing.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first()
wellbeing_state = None
if wellbeing_last_record_date:
if todate.diff(wellbeing_last_record_date[0]).in_days() > 21:
wellbeing_state = "danger bold"
elif todate.diff(wellbeing_last_record_date[0]).in_days() > 14:
wellbeing_state = "danger"
elif todate.diff(wellbeing_last_record_date[0]).in_days() > 7:
wellbeing_state = "warning"
else:
wellbeing_state = None
height_weight_last_record_date = HeightWeight.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first()
height_weight_state = None
if height_weight_last_record_date:
if todate.diff(height_weight_last_record_date[0]).in_days() > 21:
height_weight_state = "danger bold"
elif todate.diff(height_weight_last_record_date[0]).in_days() > 14:
height_weight_state = "danger"
elif todate.diff(height_weight_last_record_date[0]).in_days() > 7:
height_weight_state = "warning"
else:
height_weight_state = None
intensities_last_record_date = Intensity.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first()
intensity_state = None
if intensities_last_record_date:
if todate.diff(intensities_last_record_date[0]).in_days() > 21:
intensity_state = "danger bold"
elif todate.diff(intensities_last_record_date[0]).in_days() > 14:
intensity_state = "danger"
elif todate.diff(intensities_last_record_date[0]).in_days() > 7:
intensity_state = "warning"
else:
intensity_state = None
# points_last_update = Gymnast.objects.all().order_by("-date")[:1]
chrono_last_record_date = Chrono.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first()
chrono_state = None
if chrono_last_record_date:
if todate.diff(chrono_last_record_date[0]).in_days() > 21:
chrono_state = "danger bold"
elif todate.diff(chrono_last_record_date[0]).in_days() > 14:
chrono_state = "danger"
elif todate.diff(chrono_last_record_date[0]).in_days() > 7:
chrono_state = "warning"
else:
chrono_state = None
known_skills_last_record_date = LearnedSkill.objects.filter(gymnast=gymnast).values_list("date").order_by("-date").first()
known_skills_state = None
if known_skills_last_record_date:
if todate.diff(known_skills_last_record_date[0]).in_days() > 21:
known_skills_state = "danger bold"
elif todate.diff(known_skills_last_record_date[0]).in_days() > 14:
known_skills_state = "danger"
elif todate.diff(known_skills_last_record_date[0]).in_days() > 7:
known_skills_state = "warning"
else:
known_skills_state = None
context["wellbeing_last_record_date"] = wellbeing_last_record_date
context["wellbeing_state"] = wellbeing_state

View File

@ -107,6 +107,8 @@ def intensity_details(request, intensity_id):
if not request.user.is_superuser and (
request.session.has_key("available_gymnast")
and intensity.gymnast.id not in request.session["available_gymnast"]
) and (
intensity.gymnast.id != request.user.gymnast.id
):
return intensity_listing(request)

View File

@ -316,8 +316,10 @@ def wellbeing_details(request, wellbeing_id):
if not request.user.is_superuser and (
request.session.has_key("available_gymnast")
and wellbeing.gymnast.id not in request.session["available_gymnast"]
) and (
wellbeing.gymnast.id != request.user.gymnast.id
):
return wellbeing_listing(request)
return HttpResponseRedirect(reverse("wellbeing_list"))
return render(request, "wellbeing/details.html", {"wellbeing": wellbeing})