Compare commits
2 Commits
fdc399d941
...
b39d33caf5
Author | SHA1 | Date |
---|---|---|
Gregory Trullemans | b39d33caf5 | |
Gregory Trullemans | 81586a9aa3 |
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 3.2.8 on 2022-01-09 10:16
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('objective', '0010_auto_20220109_1001'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='touchposition',
|
||||||
|
name='allowed_in_competition',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Allowed in competition'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='touchposition',
|
||||||
|
name='is_default',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='Défault ?'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -233,6 +233,87 @@ class Routine(Educative):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s (%s)" % (self.long_label, self.short_label)
|
return "%s (%s)" % (self.long_label, self.short_label)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def max_even_if_none(value_1, value_2):
|
||||||
|
if value_1 is not None and value_2 is not None:
|
||||||
|
if value_1 > value_2:
|
||||||
|
return value_1
|
||||||
|
else:
|
||||||
|
return value_2
|
||||||
|
return None
|
||||||
|
|
||||||
|
def compute_informations(self):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
rank = 0
|
||||||
|
level = 0
|
||||||
|
age_boy_with_help = 0
|
||||||
|
age_girl_with_help = 0
|
||||||
|
age_boy_without_help = 0
|
||||||
|
age_girl_without_help = 0
|
||||||
|
age_boy_chained = 0
|
||||||
|
age_girl_chained = 0
|
||||||
|
age_boy_masterised = 0
|
||||||
|
age_girl_masterised = 0
|
||||||
|
difficulty = 0
|
||||||
|
is_competitive = True
|
||||||
|
|
||||||
|
for skill_link in self.skill_links.all():
|
||||||
|
skill = skill_link.skill
|
||||||
|
|
||||||
|
difficulty += skill.difficulty
|
||||||
|
level = max(skill.level, level)
|
||||||
|
rank = max(skill.rank + 1, rank)
|
||||||
|
|
||||||
|
if not skill.is_competitive:
|
||||||
|
is_competitive = False
|
||||||
|
|
||||||
|
# Age boy computing
|
||||||
|
age_boy_with_help = max_even_if_none(skill.age_boy_with_help, age_boy_with_help)
|
||||||
|
age_boy_without_help = max_even_if_none(
|
||||||
|
skill.age_boy_without_help,
|
||||||
|
age_boy_without_help
|
||||||
|
)
|
||||||
|
age_boy_chained = max_even_if_none(skill.age_boy_chained, age_boy_chained)
|
||||||
|
age_boy_masterised = max_even_if_none(skill.age_boy_masterised, age_boy_masterised)
|
||||||
|
|
||||||
|
# Age girl computing
|
||||||
|
age_girl_with_help = max_even_if_none(skill.age_girl_with_help, age_girl_with_help)
|
||||||
|
age_girl_without_help = max_even_if_none(
|
||||||
|
skill.age_girl_without_help,
|
||||||
|
age_girl_without_help
|
||||||
|
)
|
||||||
|
age_girl_chained = max_even_if_none(skill.age_girl_chained, age_girl_chained)
|
||||||
|
age_girl_masterised = max_even_if_none(skill.age_girl_masterised, age_girl_masterised)
|
||||||
|
|
||||||
|
|
||||||
|
if self.skill_links.all().count() != 10:
|
||||||
|
is_competitive = False
|
||||||
|
|
||||||
|
self.difficulty = difficulty
|
||||||
|
self.level = max(self.level, level)
|
||||||
|
self.rank = max(self.rank, rank)
|
||||||
|
|
||||||
|
self.age_boy_with_help = max(self.age_boy_with_help, age_boy_with_help)
|
||||||
|
self.age_boy_without_help = max(
|
||||||
|
self.age_boy_without_help,
|
||||||
|
age_boy_without_help
|
||||||
|
)
|
||||||
|
self.age_boy_chained = max(self.age_boy_chained, age_boy_chained)
|
||||||
|
self.age_boy_masterised = max(self.age_boy_masterised, age_boy_masterised)
|
||||||
|
|
||||||
|
self.age_girl_with_help = max(self.age_girl_with_help, age_girl_with_help)
|
||||||
|
self.age_girl_without_help = max(
|
||||||
|
self.age_girl_without_help,
|
||||||
|
age_girl_without_help
|
||||||
|
)
|
||||||
|
self.age_girl_chained = max(self.age_girl_chained, age_girl_chained)
|
||||||
|
self.age_girl_masterised = max(self.age_girl_masterised, age_girl_masterised)
|
||||||
|
|
||||||
|
self.is_competitive = is_competitive
|
||||||
|
|
||||||
|
self.save()
|
||||||
|
|
||||||
def contains_basic_jumps(self):
|
def contains_basic_jumps(self):
|
||||||
"""
|
"""
|
||||||
Renvoie True si la série contient au moins un saut de base, False sinon.
|
Renvoie True si la série contient au moins un saut de base, False sinon.
|
||||||
|
|
|
@ -171,82 +171,7 @@ def routine_details(request, routineid):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
routine = get_object_or_404(Routine, pk=routineid)
|
routine = get_object_or_404(Routine, pk=routineid)
|
||||||
|
routine.compute_informations()
|
||||||
rank = 0
|
|
||||||
level = 0
|
|
||||||
age_boy_with_help = 0
|
|
||||||
age_girl_with_help = 0
|
|
||||||
age_boy_without_help = 0
|
|
||||||
age_girl_without_help = 0
|
|
||||||
age_boy_chained = 0
|
|
||||||
age_girl_chained = 0
|
|
||||||
age_boy_masterised = 0
|
|
||||||
age_girl_masterised = 0
|
|
||||||
difficulty = 0
|
|
||||||
is_competitive = True
|
|
||||||
|
|
||||||
for skill_link in routine.skill_links.all():
|
|
||||||
|
|
||||||
difficulty += skill_link.skill.difficulty
|
|
||||||
level = max(skill_link.skill.level, level)
|
|
||||||
rank = max(skill_link.skill.rank + 1, rank)
|
|
||||||
|
|
||||||
if not skill_link.skill.is_competitive:
|
|
||||||
is_competitive = False
|
|
||||||
|
|
||||||
# Age boy computing
|
|
||||||
if skill_link.skill.age_boy_with_help is not None and skill_link.skill.age_boy_with_help > age_boy_with_help:
|
|
||||||
age_boy_with_help = skill_link.skill.age_boy_with_help
|
|
||||||
|
|
||||||
if skill_link.skill.age_boy_without_help is not None and skill_link.skill.age_boy_without_help > age_boy_without_help:
|
|
||||||
age_boy_without_help = skill_link.skill.age_boy_without_help
|
|
||||||
|
|
||||||
if skill_link.skill.age_boy_chained is not None and skill_link.skill.age_boy_chained > age_boy_chained:
|
|
||||||
age_boy_chained = skill_link.skill.age_boy_chained
|
|
||||||
|
|
||||||
if skill_link.skill.age_boy_masterised is not None and skill_link.skill.age_boy_masterised > age_boy_masterised:
|
|
||||||
age_boy_masterised = skill_link.skill.age_boy_masterised
|
|
||||||
|
|
||||||
# Age girl computing
|
|
||||||
if skill_link.skill.age_girl_with_help is not None and skill_link.skill.age_girl_with_help > age_girl_with_help:
|
|
||||||
age_girl_with_help = skill_link.skill.age_girl_with_help
|
|
||||||
|
|
||||||
if skill_link.skill.age_girl_without_help is not None and skill_link.skill.age_girl_without_help > age_girl_without_help:
|
|
||||||
age_girl_without_help = skill_link.skill.age_girl_without_help
|
|
||||||
|
|
||||||
if skill_link.skill.age_girl_chained is not None and skill_link.skill.age_girl_chained > age_girl_chained:
|
|
||||||
age_girl_chained = skill_link.skill.age_girl_chained
|
|
||||||
|
|
||||||
if skill_link.skill.age_girl_masterised is not None and skill_link.skill.age_girl_masterised > age_girl_masterised:
|
|
||||||
age_girl_masterised = skill_link.skill.age_girl_masterised
|
|
||||||
|
|
||||||
if routine.skill_links.all().count() != 10:
|
|
||||||
is_competitive = False
|
|
||||||
|
|
||||||
routine.difficulty = difficulty
|
|
||||||
routine.level = max(routine.level, level)
|
|
||||||
routine.rank = max(routine.rank, rank)
|
|
||||||
|
|
||||||
routine.age_boy_with_help = max(routine.age_boy_with_help, age_boy_with_help)
|
|
||||||
routine.age_boy_without_help = max(
|
|
||||||
routine.age_boy_without_help,
|
|
||||||
age_boy_without_help
|
|
||||||
)
|
|
||||||
routine.age_boy_chained = max(routine.age_boy_chained, age_boy_chained)
|
|
||||||
routine.age_boy_masterised = max(routine.age_boy_masterised, age_boy_masterised)
|
|
||||||
|
|
||||||
routine.age_girl_with_help = max(routine.age_girl_with_help, age_girl_with_help)
|
|
||||||
routine.age_girl_without_help = max(
|
|
||||||
routine.age_girl_without_help,
|
|
||||||
age_girl_without_help
|
|
||||||
)
|
|
||||||
routine.age_girl_chained = max(routine.age_girl_chained, age_girl_chained)
|
|
||||||
routine.age_girl_masterised = max(routine.age_girl_masterised, age_girl_masterised)
|
|
||||||
|
|
||||||
routine.is_competitive = is_competitive
|
|
||||||
|
|
||||||
routine.save()
|
|
||||||
|
|
||||||
context = {"routine": routine, "skill_link_list": routine.skill_links.all()}
|
context = {"routine": routine, "skill_link_list": routine.skill_links.all()}
|
||||||
return render(request, "objectives/routines/details.html", context)
|
return render(request, "objectives/routines/details.html", context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue