Compare commits

...

4 Commits

Author SHA1 Message Date
Gregory Trullemans 9a54791ce6 Update chrono list 2022-11-19 19:45:51 +01:00
Gregory Trullemans 11dda58f56 Bugs fix 2022-11-19 19:32:16 +01:00
Gregory Trullemans 9e47dab363 remove unused function 2022-11-19 19:27:58 +01:00
Gregory Trullemans ff04388db2 Update URL 2022-11-19 19:23:10 +01:00
3 changed files with 7 additions and 69 deletions

View File

@ -42,10 +42,6 @@
<a href="{% url 'chrono_update' chrono.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
&nbsp;
<a href="{% url 'jump_chrono_values_create_or_update' chrono.id %}">
<span class="far fa-search-plus text-warning"></span>
</a>
</td>
<td>{{ chrono.date | date:"d-m-Y" }}</td>
<td class="text-left">

View File

@ -53,7 +53,7 @@ gymnast_urlpatterns = [
),
path(
r"report/<int:gymnast_id>/",
views.preview_gymnast_report,
views.generate_report,
name="gymnast_report_preview",
),
path(

View File

@ -157,70 +157,6 @@ def gymnast_details(request, gymnast_id, tab=None):
return render(request, "people/gymnasts/details.html", context)
@login_required
@require_http_methods(["GET"])
def preview_gymnast_report(request, gymnast_id):
"""Génère la preview pour le rapport"""
if request.user.groups.filter(name="trainer").exists():
gymnast = get_object_or_404(Gymnast, pk=gymnast_id)
else:
gymnast = Gymnast.objects.get(user=request.user)
gymnast_nb_known_skills = gymnast.known_skills.distinct(
"skill"
).count() # devrait disparaitre
nb_skill = Skill.objects.all().count()
nb_known_skill = (
LearnedSkill.objects.filter(gymnast=gymnast_id).distinct("skill").count()
)
if nb_skill != 0:
percentage_known_skill = (nb_known_skill / nb_skill) * 100
else:
percentage_known_skill = 0
# base_queryset = Chrono.objects.filter(gymnast=gymnast_id).order_by("-date")
chronos_list = Chrono.objects.filter(gymnast=gymnast_id).order_by("-date")[:10]
straightjump_score = (
Chrono.objects.filter(gymnast=gymnast_id)
.filter(chrono_type=0)
.order_by("-date")
)
best_straightjump = (
Chrono.objects.filter(gymnast=gymnast_id)
.filter(chrono_type=0)
.order_by("-score")[:1]
)
best_tof_routine_1 = (
Chrono.objects.filter(gymnast=gymnast_id)
.filter(chrono_type=1)
.order_by("-score")[:1]
)
best_tof_routine_2 = (
Chrono.objects.filter(gymnast=gymnast_id)
.filter(chrono_type=2)
.order_by("-score")[:1]
)
context = {
"gymnast": gymnast,
"gymnast_nb_known_skills": gymnast_nb_known_skills,
"chronos_list": chronos_list,
"straightjump_score": straightjump_score,
"best_tof_routine_1": best_tof_routine_1,
"best_tof_routine_2": best_tof_routine_2,
"best_straightjump": best_straightjump,
"nb_skill": nb_skill,
"nb_known_skill": nb_known_skill,
"percentage_known_skill": percentage_known_skill,
}
context["user_is_trainer"] = request.user.groups.filter(
name="trainer"
).exists() # TODO: utiliser les {{ perms }}
return render(request, "people/gymnasts/report.html", context)
@login_required
@require_http_methods(["GET"])
def generate_gymnast_report(request, gymnast_id):
@ -629,6 +565,8 @@ def generate_report(request, gymnast_id):
have_physiological = False
if lasts_mindstate:
mindstate_analyse = analyse_score(last_mindstate.score, lasts_mindstate)
else:
mindstate_analyse = None
height_weight_queryset = HeightWeight.objects.filter(gymnast=gymnast).order_by(
"-date"
@ -639,9 +577,13 @@ def generate_report(request, gymnast_id):
if lasts_height:
height_analyse = analyse_score(last_height_weigth.height, lasts_height)
else:
height_analyse = None
if lasts_weight:
weight_analyse = analyse_score(last_height_weigth.weight, lasts_weight)
else:
weight_analyse = None
#
# BEST TOF