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/ -->
<script src="{% static "js/plugins/bootstrap-datetimepicker_4.17.47.js" %}"></script>
<!-- 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 -->
<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 -->

View File

@ -46,7 +46,7 @@
</div>
</div>
<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 %}">
{{ 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 %}

View File

@ -4,19 +4,19 @@
<div class="col-md-12">
<div class="card">
<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">
{% if planified_skill %}
{% if planned_skill %}
<li class="nav-item">
<a class="nav-link {% if planified_skill %}active{% endif %}" data-toggle="tab" href="#planified_skill">
Objectives <!-- ({{ planified_skill|length }}) -->
<a class="nav-link {% if planned_skill %}active{% endif %}" data-toggle="tab" href="#planned_skill">
Objectives <!-- ({{ planned_skill|length }}) -->
</a>
</li>
{% endif %}
{% if skill_whith_help %}
<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 }}) -->
</a>
</li>
@ -24,7 +24,7 @@
{% if skill_without_help %}
<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 }}) -->
</a>
</li>
@ -32,7 +32,7 @@
{% if skill_chained %}
<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 }}) -->
</a>
</li>
@ -40,7 +40,7 @@
{% if skill_by_rank %}
<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 }}) -->
</a>
</li>
@ -48,7 +48,7 @@
{% if skill_by_level %}
<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 }}) -->
</a>
</li>
@ -56,7 +56,7 @@
{% if skill_by_age %}
<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 }}) -->
</a>
</li>
@ -64,16 +64,16 @@
{% if unknown_skill %}
<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
</a>
</li>
{% endif %}
</ul>
<div class="tab-content tab-space tab-subcategories pt-0 pb-0">
{% if planified_skill %}
<div class="tab-pane {% if planified_skill %}active{% endif %}" id="planified_skill">
<table class="table table-condensed table-striped tablesorter" id="table_planified_skill">
{% if planned_skill %}
<div class="tab-pane {% if planned_skill %}active{% endif %}" id="planned_skill">
<table class="table table-condensed table-striped tablesorter" id="table_planned_skill">
<thead>
<tr>
{% if user_is_trainer %}
@ -88,36 +88,39 @@
</tr>
</thead>
<tbody>
{% for skill in planified_skill %}
{% for plan in planned_skill %}
<tr>
{% if user_is_trainer %}
<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>
</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>
</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>
</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>
</button>
</td>
{% endif %}
<td>{{ skill.notation }}</td>
<td>{{ plan.educative.skill.notation }}</td>
<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>
{% if skill.is_past %}<span class="text-danger"><b>{% endif %}
{{ skill.plan_date | date:"d-m-Y" }}
{% if skill.is_past %}</b></span>{% endif %}
{% if plan.is_past %}<span class="text-danger"><b>{% endif %}
{{ plan.date | date:"d-m-Y" }}
{% if plan.is_past %}</b></span>{% endif %}
</td>
<td>{{ skill.difficulty }}</td>
<td>{{ skill.level }}</td>
<td>{{ skill.rank }}</td>
<td>{{ plan.educative.difficulty }}</td>
<td>{{ plan.educative.level }}</td>
<td>{{ plan.educative.rank }}</td>
</tr>
{% endfor %}
</tbody>
@ -126,7 +129,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -169,7 +172,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -209,7 +212,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -246,7 +249,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -297,7 +300,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -348,7 +351,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -400,7 +403,7 @@
{% endif %}
{% 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">
<thead>
<tr>
@ -503,7 +506,7 @@
sortList: [[5,0], [4,0], [2,0]]
});
$('#table_planified_skill').tablesorter({
$('#table_planned_skill').tablesorter({
{% if user_is_trainer %}
headers: {
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>
</div>
<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/>
<br/>
</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()
from datetime import date
import pendulum
from ultron.tools.models import Markdownizable, Seasonisable
from ultron.people.models import Gymnast
@ -206,9 +207,6 @@ class Plan(Seasonisable, Markdownizable):
self.date,
)
# @property
# def is_due(self):
# return pendulum.now().date() > self.date
class Point(models.Model):
"""
@ -358,7 +356,13 @@ class HeightWeight(Seasonisable):
on_delete=models.CASCADE,
)
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")
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/<int:plan_id>/edit/", views.plan_create_or_update, name="plan_update"),
path(
r"plan/add/<int:gymnast_id>/",
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 = {
"gymnast": plan.gymnast.id,
"gymnast_related": str(plan.gymnast),
"skill": plan.skill.id,
"skill_related": str(plan.skill),
"educative": plan.educative.id,
"educative_related": str(plan.educative),
}
else:
plan = None

View File

@ -6,7 +6,8 @@ from ultron.tools.models import 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 = (
@ -68,6 +69,7 @@ class Educative(Markdownizable):
age_girl_masterised = models.PositiveSmallIntegerField(
choices=AGE_CHOICES, verbose_name="Girl's age masterised", default=6
)
# is_competitive = models.BooleanField(default=False)
def __str__(self):
return "%s (%s - %s)" % (
@ -152,7 +154,8 @@ def get_default_position():
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`
@ -201,11 +204,11 @@ class Skill(Educative):
rotation_type = models.PositiveSmallIntegerField(
choices=ROTATION_CHOICES, verbose_name="Type de rotation"
)
rotation = models.PositiveSmallIntegerField(verbose_name="1/4 de rotation")
twist = models.PositiveSmallIntegerField(verbose_name="1/2 Vrille")
notation = models.CharField(max_length=25)
rotation = models.PositiveSmallIntegerField(verbose_name="¼ de rotation")
twist = models.PositiveSmallIntegerField(verbose_name="½ Vrille")
notation = models.CharField(max_length=10)
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)
# importance = models.PositiveSmallIntegerField(default = 1)
@ -216,7 +219,8 @@ class Skill(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:

View File

@ -19,6 +19,7 @@ from ultron.followup.models import Event
from ultron.followup.forms import GymnastHasRoutineForm
from ultron.followup.models import (
Note,
Plan,
Skill,
Point,
Chrono,
@ -459,19 +460,17 @@ def gymnast_display_skill(request, gymnast_id):
context = gymnast.get_informations_from_type("level")
context.update(gymnast.get_informations_from_type("rank"))
planified_skill = (
Skill.objects.filter(plan__gymnast=gymnast.id)
.order_by("-plan__date")
.annotate(
plan_date=F("plan__date"),
is_past=ExpressionWrapper(
Q(plan__date__lte=pendulum.now().date()),
output_field=BooleanField()
)
)
# planned_skill = (
# Plan.objects.filter(gymnast=gymnast.id, educative__in=(Skill.objects.all()))
# .order_by("-date", 'educative__long_label')
# )
planned_skill = (
Plan.objects.filter(gymnast=gymnast.id, educative__in=(Skill.objects.all())).select_related('educative', 'educative__skill')
.order_by("-date", 'educative__long_label')
)
context["planified_skill"] = planified_skill
context["planned_skill"] = planned_skill
if gymnast.gender:
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)
super().save(*args, **kwargs)
@property
def is_past(self):
return pendulum.now().date() > self.date
class TemporizableQuerySet(models.QuerySet):
"""