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

View File

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

View File

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

View File

@ -316,8 +316,10 @@ def wellbeing_details(request, wellbeing_id):
if not request.user.is_superuser and ( if not request.user.is_superuser and (
request.session.has_key("available_gymnast") request.session.has_key("available_gymnast")
and wellbeing.gymnast.id not in request.session["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}) return render(request, "wellbeing/details.html", {"wellbeing": wellbeing})