Add passe and trainingprogram model
This commit is contained in:
parent
23e00ef131
commit
1d99ed6568
|
@ -29,7 +29,7 @@
|
|||
<th style="width: 3%"> </th>
|
||||
<th style="width: 8%" class="header">Date</th>
|
||||
{% if not gymnast %}
|
||||
<th style="width: 18%" class="header text-left">Gymnast</th>
|
||||
<th style="width: 18%" class="header text-left">Gymnast</th>
|
||||
{% endif %}
|
||||
|
||||
<th style="width: 7%" class="header text-center">Time</th>
|
||||
|
|
|
@ -211,6 +211,16 @@ class PasseAdmin(admin.ModelAdmin):
|
|||
class TrainingProgramAdmin(admin.ModelAdmin):
|
||||
model = TrainingProgram
|
||||
|
||||
fields = (
|
||||
"gymnast",
|
||||
"date",
|
||||
"rank",
|
||||
"passe",
|
||||
"repetition",
|
||||
"number_of_skill",
|
||||
"difficulty",
|
||||
# "score",
|
||||
)
|
||||
list_display = ("date", "gymnast", "passe", "rank")
|
||||
list_filter = (
|
||||
("gymnast", RelatedDropdownFilter),
|
||||
|
|
|
@ -474,7 +474,7 @@ class Passe(Markdownizable):
|
|||
def save(self, *args, **kwargs):
|
||||
"""Sauve les informations de la personne et initialise les champs nettoyés."""
|
||||
self.difficulty = 0
|
||||
self.number_of_skill = 1
|
||||
self.number_of_skill = 0
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
for educative in self.educatives.all():
|
||||
|
@ -487,6 +487,7 @@ class Passe(Markdownizable):
|
|||
|
||||
if is_skill:
|
||||
self.difficulty += educative.difficulty
|
||||
self.number_of_skill += 1
|
||||
else:
|
||||
if self.regexp is not None:
|
||||
regexp = self.regexp.replace("[", "").replace("]", "")
|
||||
|
@ -530,6 +531,14 @@ class Passe(Markdownizable):
|
|||
class TrainingProgram(Seasonisable):
|
||||
"""Classe représentant un entraînement (ensemble de passage)."""
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Training Program"
|
||||
verbose_name_plural = "Trainings Programs"
|
||||
ordering = [
|
||||
"rank",
|
||||
]
|
||||
unique_together = ["date", "rank"]
|
||||
|
||||
gymnast = models.ForeignKey("people.Gymnast", on_delete=models.CASCADE)
|
||||
passe = models.ForeignKey(Passe, on_delete=models.CASCADE)
|
||||
repetition = models.PositiveSmallIntegerField(default=1)
|
||||
|
@ -543,3 +552,10 @@ class TrainingProgram(Seasonisable):
|
|||
return (
|
||||
f"{self.gymnast} {self.date} - {self.rank} : {self.passe} {self.repetition}"
|
||||
)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Sauve les informations de la personne et initialise les champs nettoyés."""
|
||||
super().save(*args, **kwargs)
|
||||
self.difficulty = self.passe.difficulty * self.repetition
|
||||
self.number_of_skill = self.passe.number_of_skill * self.repetition
|
||||
super().save(*args, **kwargs)
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
const csrf_token = "{{ csrf_token|escapejs }}";
|
||||
const skill_lookup = "{% url 'skill_lookup' %}";
|
||||
// var landing_position = 0
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#id_skill').focus();
|
||||
|
@ -92,6 +93,7 @@
|
|||
label: item.Name,
|
||||
value: item.Name,
|
||||
skillid: item.ID,
|
||||
// landingid: item.landing.ID,
|
||||
notation: item.Notation,
|
||||
}
|
||||
}))
|
||||
|
@ -118,6 +120,7 @@
|
|||
csrfmiddlewaretoken: '{{ csrf_token }}'
|
||||
},
|
||||
}).done(function() {
|
||||
// landing_position_id = ui.item.landingid;
|
||||
insert_selected_skill(ui.item.notation);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
<div class="col-6 text-center">Routine : <a href="#">{% if routine.is_routine %}Yes{% else %}No{% endif %}</a></div>
|
||||
<div class="col-6 text-center">Competition : <a href="#">{% if routine.is_competitive %}Yes{% else %}No{% endif %}</a></div>
|
||||
</div>
|
||||
{{ combination_string }}
|
||||
|
||||
{% else %}
|
||||
<p>No skill defined for this combination.</p>
|
||||
|
|
|
@ -9,17 +9,27 @@
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
{% if trainingprogram_list %}
|
||||
<table>
|
||||
<table class="table table-striped tablesorter" id="trainingprogram_table">
|
||||
<thead>
|
||||
<td colspan="3" class="text-center">--DATE--</td>
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">{{ date|date:"l d F Y" }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for trainingprogram in trainingprogram_list %}
|
||||
<tr>
|
||||
<td>{{ trainingprogram.passe.label }} {{ trainingprogram.passe.repetition }}</td>
|
||||
<td><b>{{ trainingprogram.passe.number_of_skill}}</b></td>
|
||||
<td>{{ trainingprogram.passe.difficulty }}</td>
|
||||
</tr>
|
||||
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
||||
<td>{{ trainingprogram.rank }}</td>
|
||||
<td>{{ trainingprogram.passe.label }} {{ trainingprogram.passe.repetition }}</td>
|
||||
<td class="text-center"><b>{{ trainingprogram.passe.number_of_skill}}</b></td>
|
||||
<td class="text-center">{{ trainingprogram.passe.difficulty }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tr>
|
||||
<td colspan="2" class="text-right"><b>TOTAL</b></td>
|
||||
<td class="text-center"><b>{{ number_of_skill }}</b></td>
|
||||
<td class="text-center"><b>{{ difficulty }}</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -5,6 +5,8 @@ from django.shortcuts import render, get_object_or_404
|
|||
from django.views.decorators.http import require_http_methods
|
||||
from django.urls import reverse
|
||||
|
||||
import pendulum
|
||||
|
||||
from jarvis.people.models import Gymnast
|
||||
|
||||
from .forms import (
|
||||
|
@ -565,13 +567,25 @@ def trainingprogram_details(request, date=None, gymnast_id=None):
|
|||
else:
|
||||
trainingprogram = None
|
||||
trainingprogram_list = TrainingProgram.objects.all()
|
||||
parsed_date = pendulum.parse(date).date()
|
||||
if date is not None:
|
||||
trainingprogram_list = trainingprogram_list.filter(date=date)
|
||||
trainingprogram_list = trainingprogram_list.filter(date=parsed_date)
|
||||
|
||||
if gymnast_id is not None:
|
||||
trainingprogram_list = trainingprogram_list.filter(gymnast=gymnast_id)
|
||||
|
||||
# trainingprogram_list = trainingprogram_list.order_by("rank")
|
||||
|
||||
difficulty = 0
|
||||
number_of_skill = 0
|
||||
for trainingprogram in trainingprogram_list:
|
||||
difficulty += trainingprogram.difficulty
|
||||
number_of_skill += trainingprogram.number_of_skill
|
||||
|
||||
context = {
|
||||
"date": parsed_date,
|
||||
"difficulty": difficulty,
|
||||
"number_of_skill": number_of_skill,
|
||||
"trainingprogram": trainingprogram,
|
||||
"trainingprogram_list": trainingprogram_list,
|
||||
}
|
||||
|
|
|
@ -75,6 +75,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center ml-1">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Training Program</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if date_list %}
|
||||
{% for date in date_list %}
|
||||
<a href="{% url 'trainingprogram_details' date gymnast_id %}">{{ date }}</a>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
Pas de training planifié.
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-footer text-right text-muted pt-0">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var timeFormat = 'DD-MM-YYYY';
|
||||
|
|
|
@ -20,6 +20,7 @@ import pendulum
|
|||
|
||||
from jarvis.followup.models import Event
|
||||
from jarvis.followup.forms import GymnastHasRoutineForm
|
||||
from jarvis.objective.models import TrainingProgram
|
||||
from jarvis.followup.models import (
|
||||
Note,
|
||||
Plan,
|
||||
|
@ -255,6 +256,12 @@ def gymnast_display_scores_chrono(request, gymnast_id):
|
|||
gymnast=gymnast_id, date__gte=start_date
|
||||
).order_by("date")
|
||||
base_queryset = chrono_list.values("date").annotate(score_avg=Avg("tof"))
|
||||
today = pendulum.now().date()
|
||||
date_list = (
|
||||
TrainingProgram.objects.filter(gymnast=gymnast_id, date__gte=today)
|
||||
.values_list("date", flat=True)
|
||||
.distinct()
|
||||
)
|
||||
|
||||
context = {
|
||||
"intensity_list": intensity_list,
|
||||
|
@ -263,6 +270,7 @@ def gymnast_display_scores_chrono(request, gymnast_id):
|
|||
"chrono_r1": base_queryset.filter(chrono_type=1),
|
||||
"chrono_r2": base_queryset.filter(chrono_type=2),
|
||||
"chrono_rf": base_queryset.filter(chrono_type=3),
|
||||
"date_list": date_list,
|
||||
"gymnast_id": gymnast_id,
|
||||
}
|
||||
return render(request, "gymnasts/tabs/tab_intensity_and_chronos.html", context)
|
||||
|
|
Loading…
Reference in New Issue