diff --git a/jarvis/objective/models.py b/jarvis/objective/models.py index f769c0d..cf43b92 100644 --- a/jarvis/objective/models.py +++ b/jarvis/objective/models.py @@ -1,5 +1,5 @@ from django.db import models -from django.db.models import Q, Count +from django.db.models import Q from jarvis.tools.models import Markdownizable, max_even_if_none @@ -265,7 +265,17 @@ class Routine(Educative): return f"{self.long_label} ({self.short_label})" def compute_informations(self): - """Calcule les informations (rank, niveau, ages, …) d'une routine.""" + """Cette fonction a pour but d'assurer la cohérence des informations d'une combinaison. + La fonction vérifie : + - les âges pour les filles et garçons, + - le rang, + - le niveau, + - la difficulté + - si c'est une routine (série) + - si c'est une routine (série) de compétition + A chaque fois qu'on le peut, on garde les informations entrées par les utilisateurs néanmoins on vérifie qu'il + n'a pas encodé n'importe quoi. + """ rank = 0 level = 0 age_boy_with_help = 0 @@ -277,7 +287,8 @@ class Routine(Educative): age_boy_masterised = 0 age_girl_masterised = 0 difficulty = 0 - is_competitive = True + is_routine = False + is_competitive = False for skill_link in self.skill_links.all(): skill = skill_link.skill @@ -315,8 +326,16 @@ class Routine(Educative): skill.age_girl_masterised, age_girl_masterised ) - if self.skill_links.all().count() != 10: + if self.skill_links.all().count() < 5: + is_routine = False is_competitive = False + elif self.skill_links.all().count() != 10: + is_competitive = False + + if not self.is_routine: + is_competitive = False + + self.is_routine = is_routine self.is_competitive = is_competitive self.difficulty = difficulty diff --git a/jarvis/objective/templates/combinations/compose.html b/jarvis/objective/templates/combinations/compose.html index 1bc95ed..b9f66b4 100644 --- a/jarvis/objective/templates/combinations/compose.html +++ b/jarvis/objective/templates/combinations/compose.html @@ -63,11 +63,11 @@ $('body').on('click', '#minusButton', function(event){ $.ajax({ - url: "{% url 'unlink_skill_from_routine' %}", + url: "{% url 'unlink_skill_from_combination' %}", method: "POST", data: { - routine_id: {{ routine.id }}, - order: number_of_skill, + combination_id: {{ routine.id }}, + rank: number_of_skill, csrfmiddlewaretoken: '{{ csrf_token }}' }, }).done(function() { @@ -112,7 +112,7 @@ url: "{% url 'link_skill_to_combination' %}", method: "POST", data: { - routine_id: {{ routine.id }}, + combination_id: {{ routine.id }}, skill_id: ui.item.skillid, rank: number_of_skill, csrfmiddlewaretoken: '{{ csrf_token }}' diff --git a/jarvis/objective/templates/combinations/details.html b/jarvis/objective/templates/combinations/details.html index 095770b..39e8b99 100644 --- a/jarvis/objective/templates/combinations/details.html +++ b/jarvis/objective/templates/combinations/details.html @@ -51,7 +51,7 @@ {% endif %} diff --git a/jarvis/objective/templates/skills/details.html b/jarvis/objective/templates/skills/details.html index f675c3d..df2bc15 100644 --- a/jarvis/objective/templates/skills/details.html +++ b/jarvis/objective/templates/skills/details.html @@ -59,7 +59,7 @@

Prerequisites

-

Educatives

-