diff --git a/static/css/ultron.css b/static/css/ultron.css index 70eda9f297..c8e8df3a4b 100644 --- a/static/css/ultron.css +++ b/static/css/ultron.css @@ -68,4 +68,24 @@ a.maillink { textarea.form-control { max-height: 200px !important; +} + +.text-unknown { + color: #fd5d93 !important; +} + +.text-with-help { + color: #ff9300 !important; +} + +.text-without-help { + color: #E6E200 !important; +} + +.text-chained { + color: #04CD89 !important; +} + +.text-masterised { + color: #0CA3E0 !important; } \ No newline at end of file diff --git a/templates/people/gymnasts/tab_skill.html b/templates/people/gymnasts/tab_skill.html index 539e295659..dfe2cd2f49 100644 --- a/templates/people/gymnasts/tab_skill.html +++ b/templates/people/gymnasts/tab_skill.html @@ -95,16 +95,16 @@ - - - - diff --git a/ultron/followup/models.py b/ultron/followup/models.py index 9133fdef83..31b06d10a0 100644 --- a/ultron/followup/models.py +++ b/ultron/followup/models.py @@ -135,7 +135,7 @@ class Accident(Markdownizable, Seasonisable): updated_at = models.DateTimeField(auto_now=True) def __str__(self): - return "%s(%s)" % ( + return "%s (%s)" % ( self.gymnast, self.date, ) @@ -169,6 +169,13 @@ class LearnedSkill(Seasonisable): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + def __str__(self): + return "%s - %s - %s" % ( + self.gymnast, + self.date, + self.skill, + ) + class Plan(Seasonisable, Markdownizable): """ diff --git a/ultron/people/templatetags/skill_doughnut.py b/ultron/people/templatetags/skill_doughnut.py index 2a22aae91f..2ed6e788e0 100644 --- a/ultron/people/templatetags/skill_doughnut.py +++ b/ultron/people/templatetags/skill_doughnut.py @@ -11,52 +11,20 @@ def generate_skill_doughnut(gymnast_id): withoutRécupère les différents nombres de skill du gymnaste (masterised, chained, without help, with help or no) à la dernière date connue et les renvoie pour en faire un graphique. """ - # base_queryset = LearnedSkill.objects.filter(gymnast=gymnast_id).order_by("-date") + skill_learned_by_phase = [0] * 5 + learned_skills = LearnedSkill.objects.filter(gymnast=gymnast_id).order_by('skill_id', '-date').distinct('skill_id') - # total = 0 - # skills_capacity = [0] * 5 - # checked_skills = set() - # for learned_skill in base_queryset: - # if learned_skill not in checked_skills: - # checked_skills.add(learned_skill) - # skills_capacity[learned_skill.learning_step] += 1 - # total += 1 - - skill_whith_help = ( - Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step=1) - .exclude(known_by__gymnast=gymnast_id, known_by__learning_step__gte=2) - .distinct() - .count() - ) - - skill_without_help = ( - Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step=2) - .exclude(known_by__gymnast=gymnast_id, known_by__learning_step=3) - .distinct() - .count() - ) - - skill_chained = ( - Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step=3) - .exclude(known_by__gymnast=gymnast_id, known_by__learning_step=4) - .distinct() - .count() - ) - - skill_masterised = ( - Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step__gte=4) - .distinct() - .count() - ) + for learned_skill in learned_skills: + skill_learned_by_phase[learned_skill.learning_step] += 1 nb_skill = Skill.objects.all().count() - nb_unknown_skill = nb_skill - skill_whith_help - skill_without_help - skill_chained - skill_masterised + nb_unknown_skill = nb_skill - learned_skill.count() return { - "nb_skill_whith_help": skill_whith_help, - "nb_skill_without_help": skill_without_help, - "nb_skill_chained": skill_chained, - "nb_skill_masterised": skill_masterised, - # "lost_skill": skills_capacity[0], + "lost_skill": skill_learned_by_phase[0], + "nb_skill_whith_help": skill_learned_by_phase[1], + "nb_skill_without_help": skill_learned_by_phase[2], + "nb_skill_chained": skill_learned_by_phase[3], + "nb_skill_masterised": skill_learned_by_phase[4], "nb_unknown_skill": nb_unknown_skill, } diff --git a/ultron/people/views.py b/ultron/people/views.py index b50697f2ce..32c7c55855 100644 --- a/ultron/people/views.py +++ b/ultron/people/views.py @@ -439,7 +439,7 @@ def gymnast_create_or_update(request, gymnast_id=None): @login_required @require_http_methods(["GET"]) def gymnast_display_skill(request, gymnast_id): - """Tag affichant les statistiques de skill d'un gymnaste + """ Tag affichant les statistiques de skill d'un gymnaste Le nombre de saut qu'il sait faire (total, par niveau, par rank, …), calcule la complétude, … @@ -478,19 +478,19 @@ def gymnast_display_skill(request, gymnast_id): skill_whith_help = ( Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step=1) - .exclude(known_by__gymnast=gymnast.id, known_by__learning_step__gte=2) + .exclude(known_by__gymnast=gymnast.id, known_by__learning_step__gt=1) .distinct() ) skill_without_help = ( Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step=2) - .exclude(known_by__gymnast=gymnast.id, known_by__learning_step=3) + .exclude(known_by__gymnast=gymnast.id, known_by__learning_step__gt=2) .distinct() ) skill_chained = ( Skill.objects.filter(known_by__gymnast=gymnast_id, known_by__learning_step=3) - .exclude(known_by__gymnast=gymnast.id, known_by__learning_step=4) + .exclude(known_by__gymnast=gymnast.id, known_by__learning_step__gt=3) .distinct() )