Lots of improvement (not a good atomical commit)

This commit is contained in:
Gregory Trullemans 2022-10-18 06:16:41 +02:00
parent d1c2a33c15
commit 8a89eb0729
12 changed files with 1001 additions and 62 deletions

File diff suppressed because one or more lines are too long

View File

@ -239,7 +239,7 @@
<!-- Plugin for the DateTimePicker, full documentation here: https://eonasdan.github.io/bootstrap-datetimepicker/ --> <!-- Plugin for the DateTimePicker, full documentation here: https://eonasdan.github.io/bootstrap-datetimepicker/ -->
<script src="{% static "js/plugins/bootstrap-datetimepicker_4.17.47.js" %}"></script> <script src="{% static "js/plugins/bootstrap-datetimepicker_4.17.47.js" %}"></script>
<!-- DataTables.net Plugin, full documentation here: https://datatables.net/ --> <!-- DataTables.net Plugin, full documentation here: https://datatables.net/ -->
<script src="{% static "js/plugins/datatables/jquery.dataTables_1.10.18.min.js" %}"></script> <script src="{% static "js/plugins/datatables/datatables_1.12.1.min.js" %}"></script>
<!-- Plugin for Tags, full documentation here: https://github.com/bootstrap-tagsinput/bootstrap-tagsinputs --> <!-- Plugin for Tags, full documentation here: https://github.com/bootstrap-tagsinput/bootstrap-tagsinputs -->
<script src="{% static "js/plugins/bootstrap-tagsinput_0.8.0.js" %}"></script> <script src="{% static "js/plugins/bootstrap-tagsinput_0.8.0.js" %}"></script>
<!-- Plugin for Fileupload, full documentation here: http://www.jasny.net/bootstrap/javascript/#fileinput --> <!-- Plugin for Fileupload, full documentation here: http://www.jasny.net/bootstrap/javascript/#fileinput -->

View File

@ -46,7 +46,7 @@
</div> </div>
</div> </div>
<div class="form-group row "> <div class="form-group row ">
<label for="id_hips_height" class="col-4 col-sm-3 col-form-label">Hips Height <span class="text-danger"><b>*</b></span></label> <label for="id_hips_height" class="col-4 col-sm-3 col-form-label">Hips Height</label>
<div class="col-8 col-sm-4 col-md-3 col-lg-2 {% if form.type.errors %}has-danger{% endif %}"> <div class="col-8 col-sm-4 col-md-3 col-lg-2 {% if form.type.errors %}has-danger{% endif %}">
{{ form.hips_height }} {{ form.hips_height }}
{% if form.hips_height.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.hips_height.errors %}{{error}}{% endfor %}</span>{% endif %} {% if form.hips_height.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.hips_height.errors %}{{error}}{% endfor %}</span>{% endif %}

View File

@ -4,19 +4,19 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
{% if planified_skill or skill_whith_help or skill_without_help or skill_by_rank or skill_by_level or skill_by_age or unknown_skill %} {% if planned_skill or skill_whith_help or skill_without_help or skill_by_rank or skill_by_level or skill_by_age or unknown_skill %}
<ul class="nav nav-pills nav-pills-warning nav-pills-icons justify-content-center"> <ul class="nav nav-pills nav-pills-warning nav-pills-icons justify-content-center">
{% if planified_skill %} {% if planned_skill %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if planified_skill %}active{% endif %}" data-toggle="tab" href="#planified_skill"> <a class="nav-link {% if planned_skill %}active{% endif %}" data-toggle="tab" href="#planned_skill">
Objectives <!-- ({{ planified_skill|length }}) --> Objectives <!-- ({{ planned_skill|length }}) -->
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% if skill_whith_help %} {% if skill_whith_help %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#skill_whith_help"> <a class="nav-link {% if skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#skill_whith_help">
With help <!-- ({{ skill_whith_help|length }}) --> With help <!-- ({{ skill_whith_help|length }}) -->
</a> </a>
</li> </li>
@ -24,7 +24,7 @@
{% if skill_without_help %} {% if skill_without_help %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#skill_without_help"> <a class="nav-link {% if skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#skill_without_help">
Without help <!-- ({{ skill_without_help|length }}) --> Without help <!-- ({{ skill_without_help|length }}) -->
</a> </a>
</li> </li>
@ -32,7 +32,7 @@
{% if skill_chained %} {% if skill_chained %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if skill_chained and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#skill_chained"> <a class="nav-link {% if skill_chained and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#skill_chained">
Chained <!-- ({{ skill_without_help|length }}) --> Chained <!-- ({{ skill_without_help|length }}) -->
</a> </a>
</li> </li>
@ -40,7 +40,7 @@
{% if skill_by_rank %} {% if skill_by_rank %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if skill_by_rank and not skill_chained and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#skill_by_rank"> <a class="nav-link {% if skill_by_rank and not skill_chained and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#skill_by_rank">
By rank <!-- ({{ skill_by_rank|length }}) --> By rank <!-- ({{ skill_by_rank|length }}) -->
</a> </a>
</li> </li>
@ -48,7 +48,7 @@
{% if skill_by_level %} {% if skill_by_level %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#skill_by_level"> <a class="nav-link {% if skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#skill_by_level">
By level <!-- ({{ skill_by_level|length }}) --> By level <!-- ({{ skill_by_level|length }}) -->
</a> </a>
</li> </li>
@ -56,7 +56,7 @@
{% if skill_by_age %} {% if skill_by_age %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if skill_by_age and not skill_by_level and not skill_by_rank and not skill_chained and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#skill_by_age"> <a class="nav-link {% if skill_by_age and not skill_by_level and not skill_by_rank and not skill_chained and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#skill_by_age">
By Age <!-- ({{ skill_by_age|length }}) --> By Age <!-- ({{ skill_by_age|length }}) -->
</a> </a>
</li> </li>
@ -64,16 +64,16 @@
{% if unknown_skill %} {% if unknown_skill %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if unknown_skill and not skill_by_age and not skill_by_level and not skill_by_rank and not skill_chained and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" data-toggle="tab" href="#unknown_skill"> <a class="nav-link {% if unknown_skill and not skill_by_age and not skill_by_level and not skill_by_rank and not skill_chained and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" data-toggle="tab" href="#unknown_skill">
All skill All skill
</a> </a>
</li> </li>
{% endif %} {% endif %}
</ul> </ul>
<div class="tab-content tab-space tab-subcategories pt-0 pb-0"> <div class="tab-content tab-space tab-subcategories pt-0 pb-0">
{% if planified_skill %} {% if planned_skill %}
<div class="tab-pane {% if planified_skill %}active{% endif %}" id="planified_skill"> <div class="tab-pane {% if planned_skill %}active{% endif %}" id="planned_skill">
<table class="table table-condensed table-striped tablesorter" id="table_planified_skill"> <table class="table table-condensed table-striped tablesorter" id="table_planned_skill">
<thead> <thead>
<tr> <tr>
{% if user_is_trainer %} {% if user_is_trainer %}
@ -88,36 +88,39 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for skill in planified_skill %} {% for plan in planned_skill %}
<tr> <tr>
{% if user_is_trainer %} {% if user_is_trainer %}
<td> <td>
<button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ skill.id }}" data-link="1"> <a href="{% url 'plan_update' plan.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
<button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ plan.educative.id }}" data-link="1">
<i class="far fa-check"></i> <i class="far fa-check"></i>
</button> </button>
<button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ skill.id }}" data-link="2"> <button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ plan.educative.id }}" data-link="2">
<i class="far fa-check-double"></i> <i class="far fa-check-double"></i>
</button> </button>
<button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ skill.id }}" data-link="3"> <button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ plan.educative.id }}" data-link="3">
<i class="far fa-link"></i> <i class="far fa-link"></i>
</button> </button>
<button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ skill.id }}" data-link="4"> <button type="button" rel="tooltip" class="btn btn-success btn-link btn-sm btn-icon checkUnknownSkill" data-gymnastid="{{ gymnast.id }}" data-skillid="{{ plan.educative.id }}" data-link="4">
<i class="fal fa-thumbs-up"></i> <i class="fal fa-thumbs-up"></i>
</button> </button>
</td> </td>
{% endif %} {% endif %}
<td>{{ skill.notation }}</td> <td>{{ plan.educative.skill.notation }}</td>
<td class="text-left"> <td class="text-left">
<a href="{% url 'skill_details' skill.id %}">{{ skill.long_label }}</a> <a href="{% url 'skill_details' plan.educative.id %}">{{ plan.educative.long_label }}</a>
</td> </td>
<td> <td>
{% if skill.is_past %}<span class="text-danger"><b>{% endif %} {% if plan.is_past %}<span class="text-danger"><b>{% endif %}
{{ skill.plan_date | date:"d-m-Y" }} {{ plan.date | date:"d-m-Y" }}
{% if skill.is_past %}</b></span>{% endif %} {% if plan.is_past %}</b></span>{% endif %}
</td> </td>
<td>{{ skill.difficulty }}</td> <td>{{ plan.educative.difficulty }}</td>
<td>{{ skill.level }}</td> <td>{{ plan.educative.level }}</td>
<td>{{ skill.rank }}</td> <td>{{ plan.educative.rank }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@ -126,7 +129,7 @@
{% endif %} {% endif %}
{% if skill_whith_help %} {% if skill_whith_help %}
<div class="tab-pane {% if skill_whith_help and not planified_skill %}active{% endif %}" id="skill_whith_help"> <div class="tab-pane {% if skill_whith_help and not planned_skill %}active{% endif %}" id="skill_whith_help">
<table class="table table-striped table-condensed tablesorter" id="table_skill_with_help"> <table class="table table-striped table-condensed tablesorter" id="table_skill_with_help">
<thead> <thead>
<tr> <tr>
@ -169,7 +172,7 @@
{% endif %} {% endif %}
{% if skill_without_help %} {% if skill_without_help %}
<div class="tab-pane {% if skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" id="skill_without_help"> <div class="tab-pane {% if skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" id="skill_without_help">
<table class="table table-striped table-condensed tablesorter" id="table_skill_without_help"> <table class="table table-striped table-condensed tablesorter" id="table_skill_without_help">
<thead> <thead>
<tr> <tr>
@ -209,7 +212,7 @@
{% endif %} {% endif %}
{% if skill_chained %} {% if skill_chained %}
<div class="tab-pane {% if skill_chained and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" id="skill_chained"> <div class="tab-pane {% if skill_chained and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" id="skill_chained">
<table class="table table-striped table-condensed tablesorter" id="table_skill_chained"> <table class="table table-striped table-condensed tablesorter" id="table_skill_chained">
<thead> <thead>
<tr> <tr>
@ -246,7 +249,7 @@
{% endif %} {% endif %}
{% if skill_by_rank %} {% if skill_by_rank %}
<div class="tab-pane {% if skill_by_rank and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" id="skill_by_rank"> <div class="tab-pane {% if skill_by_rank and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" id="skill_by_rank">
<table class="table table-striped table-condensed tablesorter" id="table_by_rank"> <table class="table table-striped table-condensed tablesorter" id="table_by_rank">
<thead> <thead>
<tr> <tr>
@ -297,7 +300,7 @@
{% endif %} {% endif %}
{% if skill_by_level %} {% if skill_by_level %}
<div class="tab-pane {% if skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" id="skill_by_level"> <div class="tab-pane {% if skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" id="skill_by_level">
<table class="table table-striped table-condensed tablesorter" id="table_by_level"> <table class="table table-striped table-condensed tablesorter" id="table_by_level">
<thead> <thead>
<tr> <tr>
@ -348,7 +351,7 @@
{% endif %} {% endif %}
{% if skill_by_age %} {% if skill_by_age %}
<div class="tab-pane {% if skill_by_age and not skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" id="skill_by_age"> <div class="tab-pane {% if skill_by_age and not skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" id="skill_by_age">
<table class="table table-striped table-condensed tablesorter" id="table_by_age"> <table class="table table-striped table-condensed tablesorter" id="table_by_age">
<thead> <thead>
<tr> <tr>
@ -400,7 +403,7 @@
{% endif %} {% endif %}
{% if unknown_skill %} {% if unknown_skill %}
<div class="tab-pane {% if unknown_skill and not skill_by_age and not skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planified_skill %}active{% endif %}" id="unknown_skill"> <div class="tab-pane {% if unknown_skill and not skill_by_age and not skill_by_level and not skill_by_rank and not skill_without_help and not skill_whith_help and not planned_skill %}active{% endif %}" id="unknown_skill">
<table class="table table-striped table-condensed tablesorter" id="table_unknown_skill"> <table class="table table-striped table-condensed tablesorter" id="table_unknown_skill">
<thead> <thead>
<tr> <tr>
@ -503,7 +506,7 @@
sortList: [[5,0], [4,0], [2,0]] sortList: [[5,0], [4,0], [2,0]]
}); });
$('#table_planified_skill').tablesorter({ $('#table_planned_skill').tablesorter({
{% if user_is_trainer %} {% if user_is_trainer %}
headers: { headers: {
0: { sorter: false }, // disable first column 0: { sorter: false }, // disable first column

View File

@ -11,7 +11,7 @@
<h4 class=""><i class="icon-primary fal fa-laugh-wink"></i> Hi {{ user.username }} !</h4> <h4 class=""><i class="icon-primary fal fa-laugh-wink"></i> Hi {{ user.username }} !</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
Welcome to Ultron v0.60 <span class="text-muted">(last update : 17-10-2022)</span><br /> Welcome to Ultron v0.61 <span class="text-muted">(last update : 18-10-2022)</span><br />
This application is here to help us to manage the gymnasts (evolution, evaluation, routines, scores, …). This tool is not perfect so feel free to make improvement proposals, bug reports, … by sending me an <a href="mailto:gregory@flyingacrobaticstrampoline.be">email</a>.<br/> This application is here to help us to manage the gymnasts (evolution, evaluation, routines, scores, …). This tool is not perfect so feel free to make improvement proposals, bug reports, … by sending me an <a href="mailto:gregory@flyingacrobaticstrampoline.be">email</a>.<br/>
<br/> <br/>
</div> </div>

View File

@ -0,0 +1,24 @@
# Generated by Django 4.1.1 on 2022-10-18 03:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("followup", "0029_plan_informations"),
]
operations = [
migrations.AlterField(
model_name="heightweight",
name="hips_height",
field=models.DecimalField(
blank=True,
decimal_places=1,
max_digits=4,
null=True,
verbose_name="Hips height",
),
),
]

View File

@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model
User = get_user_model() User = get_user_model()
from datetime import date from datetime import date
import pendulum
from ultron.tools.models import Markdownizable, Seasonisable from ultron.tools.models import Markdownizable, Seasonisable
from ultron.people.models import Gymnast from ultron.people.models import Gymnast
@ -206,9 +207,6 @@ class Plan(Seasonisable, Markdownizable):
self.date, self.date,
) )
# @property
# def is_due(self):
# return pendulum.now().date() > self.date
class Point(models.Model): class Point(models.Model):
""" """
@ -358,7 +356,13 @@ class HeightWeight(Seasonisable):
on_delete=models.CASCADE, on_delete=models.CASCADE,
) )
height = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Height") height = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Height")
hips_height = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Hips height") hips_height = models.DecimalField(
max_digits=4,
decimal_places=1,
verbose_name="Hips height",
null=True,
blank=True
)
weight = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Weight") weight = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Weight")
def __str__(self): def __str__(self):

View File

@ -143,6 +143,7 @@ urlpatterns = [
path(r"plan/add/", views.plan_create_or_update, name="plan_create"), path(r"plan/add/", views.plan_create_or_update, name="plan_create"),
path(r"plan/<int:plan_id>/edit/", views.plan_create_or_update, name="plan_update"),
path( path(
r"plan/add/<int:gymnast_id>/", r"plan/add/<int:gymnast_id>/",
views.plan_create_or_update, views.plan_create_or_update,

View File

@ -645,8 +645,8 @@ def plan_create_or_update(request, plan_id=None, gymnast_id=None, skill_id=None)
data = { data = {
"gymnast": plan.gymnast.id, "gymnast": plan.gymnast.id,
"gymnast_related": str(plan.gymnast), "gymnast_related": str(plan.gymnast),
"skill": plan.skill.id, "educative": plan.educative.id,
"skill_related": str(plan.skill), "educative_related": str(plan.educative),
} }
else: else:
plan = None plan = None

View File

@ -6,7 +6,8 @@ from ultron.tools.models import Markdownizable
class Educative(Markdownizable): class Educative(Markdownizable):
""" """
Classe `mère`. Classe `mère` educative. En trampoline tout est un éducatif : un saut, un enchainement, une
série de compétition, .
""" """
AGE_CHOICES = ( AGE_CHOICES = (
@ -68,6 +69,7 @@ class Educative(Markdownizable):
age_girl_masterised = models.PositiveSmallIntegerField( age_girl_masterised = models.PositiveSmallIntegerField(
choices=AGE_CHOICES, verbose_name="Girl's age masterised", default=6 choices=AGE_CHOICES, verbose_name="Girl's age masterised", default=6
) )
# is_competitive = models.BooleanField(default=False)
def __str__(self): def __str__(self):
return "%s (%s - %s)" % ( return "%s (%s - %s)" % (
@ -152,7 +154,8 @@ def get_default_position():
class Skill(Educative): class Skill(Educative):
""" """
Classe représentant une figure (aka un saut acrobatique). Classe représentant une figure (un mouvement, un saut acrobatique). Elle hérite de la classe
`Educative`.
""" """
# SELECT * FROM `objective_skill` # SELECT * FROM `objective_skill`
@ -201,11 +204,11 @@ class Skill(Educative):
rotation_type = models.PositiveSmallIntegerField( rotation_type = models.PositiveSmallIntegerField(
choices=ROTATION_CHOICES, verbose_name="Type de rotation" choices=ROTATION_CHOICES, verbose_name="Type de rotation"
) )
rotation = models.PositiveSmallIntegerField(verbose_name="1/4 de rotation") rotation = models.PositiveSmallIntegerField(verbose_name="¼ de rotation")
twist = models.PositiveSmallIntegerField(verbose_name="1/2 Vrille") twist = models.PositiveSmallIntegerField(verbose_name="½ Vrille")
notation = models.CharField(max_length=25) notation = models.CharField(max_length=10)
simplified_notation = models.CharField( simplified_notation = models.CharField(
max_length=25, verbose_name="Notation simplifiée" max_length=10, verbose_name="Notation simplifiée"
) )
is_competitive = models.BooleanField(default=False) is_competitive = models.BooleanField(default=False)
# importance = models.PositiveSmallIntegerField(default = 1) # importance = models.PositiveSmallIntegerField(default = 1)
@ -216,7 +219,8 @@ class Skill(Educative):
class Routine(Educative): class Routine(Educative):
""" """
Classe représentant une série (enchainement de plusieurs figures). Classe représentant une série (enchainement de plusieurs figures). Elle hérite de la classe
`Educative`.
""" """
class Meta: class Meta:

View File

@ -19,6 +19,7 @@ from ultron.followup.models import Event
from ultron.followup.forms import GymnastHasRoutineForm from ultron.followup.forms import GymnastHasRoutineForm
from ultron.followup.models import ( from ultron.followup.models import (
Note, Note,
Plan,
Skill, Skill,
Point, Point,
Chrono, Chrono,
@ -459,19 +460,17 @@ def gymnast_display_skill(request, gymnast_id):
context = gymnast.get_informations_from_type("level") context = gymnast.get_informations_from_type("level")
context.update(gymnast.get_informations_from_type("rank")) context.update(gymnast.get_informations_from_type("rank"))
planified_skill = ( # planned_skill = (
Skill.objects.filter(plan__gymnast=gymnast.id) # Plan.objects.filter(gymnast=gymnast.id, educative__in=(Skill.objects.all()))
.order_by("-plan__date") # .order_by("-date", 'educative__long_label')
.annotate( # )
plan_date=F("plan__date"),
is_past=ExpressionWrapper( planned_skill = (
Q(plan__date__lte=pendulum.now().date()), Plan.objects.filter(gymnast=gymnast.id, educative__in=(Skill.objects.all())).select_related('educative', 'educative__skill')
output_field=BooleanField() .order_by("-date", 'educative__long_label')
)
)
) )
context["planified_skill"] = planified_skill context["planned_skill"] = planned_skill
if gymnast.gender: if gymnast.gender:
context["skill_by_age"] = Skill.objects.filter( context["skill_by_age"] = Skill.objects.filter(

View File

@ -91,6 +91,10 @@ class Seasonisable(models.Model):
self.season, self.week_number = from_date_to_week_number(self.date) self.season, self.week_number = from_date_to_week_number(self.date)
super().save(*args, **kwargs) super().save(*args, **kwargs)
@property
def is_past(self):
return pendulum.now().date() > self.date
class TemporizableQuerySet(models.QuerySet): class TemporizableQuerySet(models.QuerySet):
""" """