Add learning step in PDF report for next skills

This commit is contained in:
Gregory Trullemans 2022-10-12 17:05:43 +02:00
parent eba366e55a
commit 0da064b3f8
2 changed files with 11 additions and 6 deletions

View File

@ -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)

View File

@ -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(