Add season informations details

This commit is contained in:
Gregory Trullemans 2024-04-17 10:12:06 +02:00
parent 8ab21746fa
commit 4b6f33c306
10 changed files with 162 additions and 19 deletions

View File

@ -734,6 +734,7 @@ class SeasonInformationForm(forms.ModelForm):
"number_of_s_and_c_hours_per_week",
"category",
"club",
"informations",
)
widgets = {
"gymnast": forms.HiddenInput(),
@ -754,6 +755,12 @@ class SeasonInformationForm(forms.ModelForm):
),
"category": forms.Select(attrs={"class": "form-control selectpicker"}),
"club": forms.HiddenInput(),
"informations": forms.Textarea(
attrs={
"class": "form-control",
"placeholder": "Informations about intensity: did you do your full program, did you stop before the end, why did you stop before the end, …", # pylint: disable=line-too-long
}
),
}
club_related = forms.CharField(

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2 on 2024-04-17 06:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("followup", "0068_seasoninformation_category"),
]
operations = [
migrations.AddField(
model_name="seasoninformation",
name="informations",
field=models.TextField(
blank=True,
help_text="Only MarkDown is authorized",
null=True,
verbose_name="Comments",
),
),
]

View File

@ -684,7 +684,7 @@ class CompetitionCategory(Markdownizable):
return f"{self.short_label}"
class SeasonInformation(models.Model):
class SeasonInformation(Markdownizable):
"""Classe représentant l'intensité d'un entraînement"""
class Meta:

View File

@ -14,6 +14,7 @@
action="{% if season_information_id %}{% url 'season_information_update' season_information_id %}{% else %}{% url 'season_information_create' %}{% endif %}"
method="post" class="form-horizontal" id="formulaire" name="formulaire">
{% csrf_token %}
<div class="form-group row ">
<label for="id_date" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Gymnast
<span class="text-danger"><b>*</b></span></label>
@ -24,6 +25,7 @@
{% if form.gymnast.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.gymnast.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_season" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Season <span class="text-danger"><b>*</b></span></label>
<div
@ -32,14 +34,16 @@
{% if form.season.errors %}<span class="btn btn-sm btn-danger-outline">{% for error in form.season.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_club" class="col-4 col-sm-3 col-form-label">Club <span class="text-danger"><b>*</b></span></label>
<div class="col-8 col-md-9 col-lg-6 {% if form.club.errors %}has-danger{% endif %}">
<div class="col-8 col-md-9 {% if form.club.errors %}has-danger{% endif %}">
{{ form.club }}
{{ form.club_related }}
{% if form.club.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.club.errors %}{{error}}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_training_sessions_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Training/week <span class="text-danger"><b>*</b></span></label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.number_of_training_sessions_per_week.errors %}has-danger{% endif %}">
@ -47,6 +51,7 @@
{% if form.number_of_training_sessions_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_training_sessions_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_hours_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Hours/week <span class="text-danger"><b>*</b></span></label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.number_of_hours_per_week.errors %}has-danger{% endif %}">
@ -54,6 +59,7 @@
{% if form.number_of_hours_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_hours_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_s_and_c_sessions_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">S&C Training/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.number_of_s_and_c_sessions_per_week.errors %}has-danger{% endif %}">
@ -61,6 +67,7 @@
{% if form.number_of_s_and_c_sessions_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_s_and_c_sessions_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_s_and_c_hours_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">S&C Hours/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.numbernumber_of_s_and_c_hours_per_week_of_hours_per_week.errors %}has-danger{% endif %}">
@ -68,6 +75,7 @@
{% if form.number_of_s_and_c_hours_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_s_and_c_hours_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_category" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Category <span class="text-danger"><b>*</b></span></label>
<div class="col-sm-3 col-md-3 col-lg-3 {% if form.category.errors %}has-danger{% endif %}">
@ -75,6 +83,16 @@
{% if form.category.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.category.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_information" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Informations</label>
</div>
<div class="form-group row">
<div class="col-12 {% if form.id_informations.errors %}has-danger{% endif %}">
{{ form.informations }}
</div>
</div>
<div class="form-group text-center">
<input type="submit" value="{% if note_id %}Update{% else %}Add{% endif %}"
class="btn btn-warning" />

View File

@ -0,0 +1,80 @@
{% extends "base.html" %}
{% block content %}
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-8 col-lg-6 col-xl-6">
<div class="card">
<div class="card-header">
<h4 class="">{{ season_information.gymnast }}' Season {{ season_information.season }} informations</h4>
</div>
<div class="card-body">
<form class="form-horizontal" id="formulaire" name="formulaire">
{% csrf_token %}
<div class="form-group row mb-0">
<label for="id_season" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Season</label>
<div class="col-sm-3 col-md-4 col-lg-4 col-xl-3 pt-2">
{{ season_information.season }}
</div>
</div>
<div class="form-group row mb-0">
<label for="id_club" class="col-4 col-sm-3 col-form-label">Club</label>
<div class="col-8 col-md-9 pt-2">
{{ season_information.club.name }}
</div>
</div>
<div class="form-group row mb-0">
<label for="id_number_of_training_sessions_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Training/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 pt-2">
{{ season_information.number_of_training_sessions_per_week }} t/w
</div>
</div>
<div class="form-group row mb-0">
<label for="id_number_of_hours_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Hours/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 pt-2">
{{ season_information.number_of_hours_per_week }} h/w
</div>
</div>
<div class="form-group row mb-0">
<label for="id_number_of_s_and_c_sessions_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">S&C Training/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 pt-2">
{{ season_information.number_of_s_and_c_sessions_per_week }} t/w
</div>
</div>
<div class="form-group row mb-0">
<label for="id_number_of_s_and_c_hours_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">S&C Hours/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 pt-2">
{{ season_information.number_of_s_and_c_hours_per_week }} h/w
</div>
</div>
<div class="form-group row mb-0">
<label for="id_category" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">
Category
</label>
<div class="col-sm-3 col-md-3 col-lg-3 pt-2">
{{ season_information.category.long_label }}
</div>
</div>
{% if season_information.informations %}
<div class="form-group row mb-0">
<label for="id_information" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Informations</label>
</div>
<div class="form-group row">
<div class="col-12 ml-2">
{{ season_information.informations }}
</div>
</div>
{% endif %}
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -315,4 +315,9 @@ urlpatterns = [
views.season_information_create_or_update,
name="season_information_create_for_gymnast",
),
path(
r"season-information/details/<int:season_information_id>/",
views.season_information_details,
name="season_information_details",
),
]

View File

@ -703,10 +703,7 @@ def season_information_create_or_update(
)
return HttpResponseRedirect(
reverse(
"gymnast_details",
args=(form.cleaned_data["gymnast"].id,),
)
reverse("gymnast_details_tab", args=(season_information.gymnast.id, "season_informations"))
)
return render(request, "seasoninformations/create.html", {"form": form})
@ -744,3 +741,17 @@ def season_information_listing(request, gymnast_id=None):
context = {"season_information_list": season_information_list, "gymnast": gymnast}
return render(request, "seasoninformations/list.html", context)
@login_required
@require_http_methods(["GET"])
def season_information_details(request, season_information_id=None):
"""Détails des informations de saison pour un gymnaste.
Args:
season_information_id (int) identifiant d'un gymnaste
"""
season_information = get_object_or_404(SeasonInformation, pk=season_information_id)
context = {"season_information": season_information}
return render(request, "seasoninformations/details.html", context)

View File

@ -120,12 +120,12 @@
<div class="col-12 col-sm-11 col-md-11 col-lg-11 pr-0">
<div class="tab-content">
<div class="tab-pane{% if tab is None or tab == 'skill' %} active{% endif %}" id="skill"></div>
<div class="tab-pane{% if tab == 'season_informations' %} active{% endif %}" id="season_informations"></div>
<div class="tab-pane{% if tab == 'document' %} active{% endif %}" id="document"></div>
<div class="tab-pane{% if tab == 'routine' %} active{% endif %}" id="routine"></div>
<div class="tab-pane{% if tab == 'scores' %} active{% endif %}" id="scores"></div>
<div class="tab-pane{% if tab == 'physiological' %} active{% endif %}" id="physiological"></div>
<div class="tab-pane{% if tab == 'event' %} active{% endif %}" id="event"></div>
<div class="tab-pane{% if tab == 'season_informations' %} active{% endif %}" id="season_informations"></div>
<div class="tab-pane{% if tab == 'document' %} active{% endif %}" id="document"></div>
</div>
</div>
</div>
@ -142,12 +142,6 @@
{% if tab is None or tab == 'skill' %}
tab_url = default_url + 'skill/';
tab_div = '#skill';
{% elif tab == 'document' %}
tab_url = default_url + 'season_informations/';
tab_div = '#season_informations';
{% elif tab == 'document' %}
tab_url = default_url + 'document/';
tab_div = '#document';
{% elif tab == 'routine' %}
tab_url = default_url + 'routine/';
tab_div = '#routine';
@ -160,6 +154,12 @@
{% elif tab == 'event' %}
tab_url = default_url + 'event/';
tab_div = '#event';
{% elif tab == 'season_informations' %}
tab_url = default_url + 'season_informations/';
tab_div = '#season_informations';
{% elif tab == 'document' %}
tab_url = default_url + 'document/';
tab_div = '#document';
{% endif %}
$.ajax({

View File

@ -23,7 +23,7 @@
</div>
<div class="card-body pt-0">
{% if season_information_list %}
<table class="table tablesorter table-striped mb-0" data-sort="table" id="season_informations_table">
<table class="table tablesorter table-striped table-condensed mb-0" data-sort="table" id="season_informations_table">
<thead>
<tr>
<th></th>
@ -43,7 +43,7 @@
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-center">{{ season_information.season }}</td>
<td class="text-center"><a href="{% url 'season_information_details' season_information.id %}">{{ season_information.season }}</a></td>
<td class="text-center">{{ season_information.number_of_training_sessions_per_week }}</td>
<td class="text-center"><b>{{ season_information.number_of_hours_per_week }}</b></td>
<td class="text-center">{{ season_information.number_of_s_and_c_sessions_per_week }}</td>

View File

@ -160,9 +160,8 @@ def gymnast_details(request, gymnast_id, tab=None):
"percentage_known_skill": percentage_known_skill,
"tab": tab,
}
context["user_is_trainer"] = request.user.groups.filter(
name="trainer"
).exists() # TODO: utiliser les {{ perms }}
#TODO: utiliser les {{ perms }}
context["user_is_trainer"] = request.user.groups.filter(name="trainer").exists()
return render(request, "gymnasts/details.html", context)