From 09f54476f64c86619dd830bed932558b321183d6 Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Fri, 24 Dec 2021 12:14:03 +0100 Subject: [PATCH] Update interface for better reading and to be more informative --- templates/followup/chronos/list.html | 8 +- templates/followup/heightweight/list.html | 2 +- templates/followup/mindstates/list.html | 2 +- templates/followup/scores/list.html | 10 +- templates/objectives/routines/list.html | 2 +- templates/peoples/gymnasts/list_routine.html | 130 +++++++++---------- ultron/followup/views.py | 23 ++-- ultron/location/views.py | 4 +- ultron/objective/urls.py | 1 + ultron/objective/views.py | 23 +++- ultron/people/views.py | 4 +- 11 files changed, 115 insertions(+), 94 deletions(-) diff --git a/templates/followup/chronos/list.html b/templates/followup/chronos/list.html index 2c5ee64b1a..c1f266f764 100644 --- a/templates/followup/chronos/list.html +++ b/templates/followup/chronos/list.html @@ -4,8 +4,8 @@
-
-

Chronos listing

+
+

Chronos listing {% if gymnast %}for {{ gymnast }}{% endif %}

@@ -24,7 +24,7 @@ - + @@ -69,7 +69,7 @@ 0: { sorter: false }, // disable first column }, dateFormat: "uk", - sortList: [[3,0], [1,0]] + sortList: [[1,1], [2,1]] }) }); diff --git a/templates/followup/heightweight/list.html b/templates/followup/heightweight/list.html index 77e24ed1f4..32721d07f5 100644 --- a/templates/followup/heightweight/list.html +++ b/templates/followup/heightweight/list.html @@ -5,7 +5,7 @@
-

Height/Weight list

+

Height/Weight list {% if gymnast %}for {{ gymnast }}{% endif %}

{% if heightweight_list %} diff --git a/templates/followup/mindstates/list.html b/templates/followup/mindstates/list.html index 5ac87210b5..cdf0139bc4 100644 --- a/templates/followup/mindstates/list.html +++ b/templates/followup/mindstates/list.html @@ -5,7 +5,7 @@
-

Mind State list

+

Mind State list {% if gymnast %}for {{ gymnast }}{% endif %}

{% if mindstate_list %} diff --git a/templates/followup/scores/list.html b/templates/followup/scores/list.html index 5641fea953..cbdd2b28f0 100644 --- a/templates/followup/scores/list.html +++ b/templates/followup/scores/list.html @@ -5,16 +5,17 @@
-

Scores listing

+

Scores listing {% if gymnast %}for {{ gymnast }}{% endif %}

- {% if score_list.count >= 1 %} + {% if score_list %}
   Date Gymnast Routine
+ @@ -34,13 +35,14 @@ + - - + + {% endfor %} diff --git a/templates/objectives/routines/list.html b/templates/objectives/routines/list.html index 8cd812c603..8a73e8fd90 100644 --- a/templates/objectives/routines/list.html +++ b/templates/objectives/routines/list.html @@ -5,7 +5,7 @@
-

Routines' Listing

+

Routines' Listing {% if gymnast_id %}for {{ gymnast }}{% endif %}

diff --git a/templates/peoples/gymnasts/list_routine.html b/templates/peoples/gymnasts/list_routine.html index 3fbe9089c2..392a042c90 100644 --- a/templates/peoples/gymnasts/list_routine.html +++ b/templates/peoples/gymnasts/list_routine.html @@ -1,88 +1,80 @@ -
-
+
-

Routines

+

Actives Routines

-
- {% if ghr_list %} -
Gymnast EventDate Routine Exe. Dif. {{ score.gymnast }} {{ score.event.name }}{{ score.event.datebegin | date:"d-m-Y" }} {{ score.get_routine_type_display }} {{ score.point_execution }} {{ score.point_difficulty }} {{ score.point_time_of_flight }} {{ score.point_horizontal_displacement }}{% if score.penality > 0 %}-{{ score.penality }}{% endif %}{{ score.total }}{% if score.penality > 0 %}-{{ score.penality }}{% else %}-{% endif %}{{ score.total }}
- - - - - - - - - - - - - - {% for ghr in ghr_list %} - - - - - - - - - - - - - - - {% endfor %} - + {% if ghr_list %} +
+
TypeLabelFromToDiff.LevelRank
{{ ghr.get_routine_type_display }}{{ ghr.routine.long_label }}{{ ghr.datebegin | date:"d-m-Y"}}{% if ghr.dateend %}{{ ghr.dateend | date:"d F Y" }}{% else %}… to now.{% endif %}{{ ghr.routine.difficulty }}{{ ghr.routine.level }}{{ ghr.routine.rank }}
+ + + + + + + + + + + + {% for ghr in ghr_list %} + + + + + + + + + + {% endfor %} +
TypeLabelFromDiff.LevelRank
{{ ghr.get_routine_type_display }}{{ ghr.routine.short_label }}{{ ghr.datebegin | date:"d-m-Y"}}{{ ghr.routine.difficulty }}{{ ghr.routine.level }}{{ ghr.routine.rank }}
{% else %}

There are no routines associated to this gymnast.

{% endif %}
-
-
-
-
-
-

Routine's statistics

-
-
+
+
+
+

Routine's statistics

+
+
{% if routine_done_list %} - +
- - - + + - + {% for record in routine_done_list %} - - - - - + - @@ -107,12 +99,20 @@ diff --git a/ultron/followup/views.py b/ultron/followup/views.py index 64e7927861..d496f996ec 100644 --- a/ultron/followup/views.py +++ b/ultron/followup/views.py @@ -35,12 +35,14 @@ import simplejson def chrono_listing(request, gymnast_id=None): """Récupère la liste des chronos""" + gymnast = None if gymnast_id: chrono_list = Chrono.objects.filter(gymnast=gymnast_id) + gymnast = Gymnast.objects.get(pk=gymnast_id) else: chrono_list = Chrono.objects.all() - context = {"chrono_list": chrono_list} + context = {"chrono_list": chrono_list, "gymnast": gymnast} return render(request, "followup/chronos/list.html", context) @@ -197,17 +199,20 @@ def score_listing(request, gymnast_id=None): """ pattern = request.GET.get("pattern", None) + gymnast = None if pattern: score_list = Point.objects.filter( - Q(event__icontains=pattern) | Q(gymnast__icontains=pattern) + Q(event__icontains=pattern) + | Q(gymnast__icontains=pattern) ) elif gymnast_id: score_list = Point.objects.filter(gymnast=gymnast_id) + gymnast = Gymnast.objects.get(pk=gymnast_id) else: score_list = Point.objects.all() - context = {"score_list": score_list} + context = {"score_list": score_list, "gymnast": gymnast} return render(request, "followup/scores/list.html", context) @@ -285,15 +290,16 @@ def accident_detail(request, accidentid): @require_http_methods(["GET"]) def mindstate_listing(request, gymnast_id=None): """ - Récupère la liste des evaluations mentales suivant (d'un gymnast si définit en paramètre). + Récupère la liste des évaluations mentales suivant (d'un gymnaste si définit en paramètre). """ - + gymnast = None if gymnast_id: mindstate_list = MindState.objects.filter(gymnast=gymnast_id) + gymnast = Gymnast.objects.get(pk=gymnast_id) else: mindstate_list = MindState.objects.all() - context = {"mindstate_list": mindstate_list} + context = {"mindstate_list": mindstate_list, "gymnast": gymnast} return render(request, "followup/mindstates/list.html", context) @@ -354,13 +360,14 @@ def heightweight_listing(request, gymnast_id=None): """ Récupère la liste des couples taille/poids suivant (d'un gymnast si définit en paramètre). """ - + gymnast = None if gymnast_id: heightweight_list = HeightWeight.objects.filter(gymnast=gymnast_id) + gymnast = Gymnast.objects.get(pk=gymnast_id) else: heightweight_list = HeightWeight.objects.all() - context = {"heightweight_list": heightweight_list} + context = {"heightweight_list": heightweight_list, "gymnast": gymnast} return render(request, "followup/heightweight/list.html", context) diff --git a/ultron/location/views.py b/ultron/location/views.py index 8fe6e07813..e0ec8e2a36 100644 --- a/ultron/location/views.py +++ b/ultron/location/views.py @@ -142,7 +142,9 @@ def club_lookup(request): if pattern is not None and len(pattern) > 3: model_results = Club.objects.filter( - Q(name__icontains=pattern) | Q(place__city__icontains=pattern) | Q(acronym__icontains=pattern) + Q(name__icontains=pattern) + | Q(place__city__icontains=pattern) + | Q(acronym__icontains=pattern) ) results = [{"ID": x.id, "Name": str(x)} for x in model_results] diff --git a/ultron/objective/urls.py b/ultron/objective/urls.py index 9a4dfb3a70..9a3fe51eea 100644 --- a/ultron/objective/urls.py +++ b/ultron/objective/urls.py @@ -38,6 +38,7 @@ routine_urlpatterns = [ # ), # path(r"suggest/", views.suggest_routine, name="suggest_routine",), path(r"", views.routine_listing, name="routine_list"), + path(r"gymnast/", views.routine_listing, name="routine_list_for_gymnast"), ] # Plan diff --git a/ultron/objective/views.py b/ultron/objective/views.py index b4ffdcb540..c043e3b948 100644 --- a/ultron/objective/views.py +++ b/ultron/objective/views.py @@ -26,7 +26,8 @@ def skill_lookup(request): # Ignore queries shorter than length 2 if pattern is not None and len(pattern) > 2: model_results = Skill.objects.filter( - Q(short_label__icontains=pattern) | Q(long_label__icontains=pattern) + Q(short_label__icontains=pattern) + | Q(long_label__icontains=pattern) ) results = [ {"ID": x.id, "Name": str(x), "Notation": x.notation} for x in model_results @@ -50,7 +51,8 @@ def skill_listing(request, field=None, expression=None, value=None, level=None): if pattern: skill_list = Skill.objects.filter( - Q(long_label__icontains=pattern) | Q(short_label__icontains=pattern) + Q(long_label__icontains=pattern) + | Q(short_label__icontains=pattern) ) elif field and expression and value: kwargs = {"{0}__{1}".format(field, expression): value} @@ -99,20 +101,26 @@ def skill_details(request, skillid): @login_required @require_http_methods(["GET"]) -def routine_listing(request): +def routine_listing(request, gymnast_id=None): """ Récupère la liste des routines (série) suivant un pattern si celui-ci est définit. """ + gymnast = None pattern = request.GET.get("pattern", None) if pattern: routine_list = Routine.objects.filter( - Q(long_label__icontains=pattern) | Q(short_label__icontains=pattern) + Q(long_label__icontains=pattern) + | Q(short_label__icontains=pattern) ) else: - routine_list = Routine.objects.all() + if gymnast_id: + routine_list = Routine.objects.filter(done_by_gymnast__gymnast=gymnast_id) + gymnast = Gymnast.objects.get(pk=gymnast_id) + else: + routine_list = Routine.objects.all() - context = {"routine_list": routine_list} + context = {"routine_list": routine_list, "gymnast_id": gymnast_id, "gymnast": gymnast} return render(request, "objectives/routines/list.html", context) @@ -126,7 +134,8 @@ def routine_lookup(request): if pattern is not None and len(pattern) >= 3: results = Routine.objects.filter( - Q(long_label__icontains=pattern) | Q(short_label__icontains=pattern) + Q(long_label__icontains=pattern) + | Q(short_label__icontains=pattern) ) place_list = [{"id": x.id, "label": str(x)} for x in results] diff --git a/ultron/people/views.py b/ultron/people/views.py index 252f213b02..a3027430e8 100644 --- a/ultron/people/views.py +++ b/ultron/people/views.py @@ -294,8 +294,8 @@ def gymnast_display_routines(request, gymnast_id): Tag affichant les séries d'un gymnaste. """ gymnast = get_object_or_404(Gymnast, pk=gymnast_id) - ghr_list = gymnast.has_routine.prefetch_related("routine") - routine_done_list = NumberOfRoutineDone.objects.filter(gymnast = gymnast_id).order_by("-date") + ghr_list = gymnast.has_routine.prefetch_related("routine").filter(dateend__isnull=True) + routine_done_list = NumberOfRoutineDone.objects.filter(gymnast = gymnast_id).order_by("-date")[:8] context = {"ghr_list": ghr_list, "routine_done_list": routine_done_list, "gymnast_id": gymnast_id} return render(request, "peoples/gymnasts/list_routine.html", context)
RoutineType DateRoutineType # Try# Success# Success
{{ record.date | date:"d-m-Y"}} {{ record.routine.long_label }} {{ record.get_routine_type_display }}{{ record.date | date:"d-m-Y"}} {{ record.number_of_try }} {{ record.number_of_successes }}