diff --git a/ultron/followup/models.py b/ultron/followup/models.py index 0f53e5b13b..dee347d4dc 100644 --- a/ultron/followup/models.py +++ b/ultron/followup/models.py @@ -21,7 +21,7 @@ ROUTINE_CHOICE = ( (8, "R4S"), ) -CAN_DO_TYPE_CHOICES = ( +LEARNING_STEP_CHOICES = ( (0, "No"), (1, "With help"), (2, "Without help"), @@ -163,7 +163,7 @@ class LearnedSkill(Seasonisable): on_delete=models.CASCADE, ) cando = models.PositiveSmallIntegerField( - choices=CAN_DO_TYPE_CHOICES, verbose_name="Can do type" + choices=LEARNING_STEP_CHOICES, verbose_name="Can do type" ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) @@ -193,7 +193,7 @@ class Plan(Seasonisable): on_delete=models.CASCADE, ) cando = models.PositiveSmallIntegerField( - choices=CAN_DO_TYPE_CHOICES, verbose_name="Can do type", default=3 + choices=LEARNING_STEP_CHOICES, verbose_name="Can do type", default=3 ) is_done = models.BooleanField(default=0) created_at = models.DateTimeField(auto_now_add=True) diff --git a/ultron/tools/pdf_generator.py b/ultron/tools/pdf_generator.py index 8f6f15cce4..3cff60ebf5 100644 --- a/ultron/tools/pdf_generator.py +++ b/ultron/tools/pdf_generator.py @@ -24,6 +24,7 @@ from ultron.followup.models import ( Plan, Point ) +from ultron.followup.models import LEARNING_STEP_CHOICES from ultron.objective.models import Skill from ultron.people.models import Gymnast from ultron.planning.models import Event @@ -539,20 +540,24 @@ class GymnastReportDocument(PDFDocument): ) self.add_vspace(-3) + # le double F ne fonctionne qu'en précisant le distinct, sinon ca dédouble les résultats. + # qui lui même ne fonctionne que sur un champ présent dans le `order_by` (que le premier champ ?) + # planified_skills = ( Skill.objects.filter(plan__gymnast=gymnast.id) .filter( Q(plan__is_done=False) | Q(plan__date__gte=date.today()) ) - .annotate(plan_date=F("plan__date")) - .order_by("-plan__date").distinct()[:6] + # .annotate(plan_date=F("plan__date")) + .annotate(plan_date=F("plan__date"), step=F("plan__cando")) + .order_by("notation", "-plan__date").distinct('notation')[:6] ) if planified_skills: for planified_skill in planified_skills: self.add_new_line( - X, planified_skill.short_label + " (" + planified_skill.notation + ") for " + planified_skill.plan_date.strftime("%d-%m-%Y") + X, planified_skill.short_label + " " + str(LEARNING_STEP_CHOICES[planified_skill.step][1]).lower() + " (" + planified_skill.notation + ") for " + planified_skill.plan_date.strftime("%d-%m-%Y") ) else: self.add_new_line(