Optimize WellBeing form for smartphone

This commit is contained in:
Gregory Trullemans 2024-01-25 10:56:59 +01:00
parent a6edc1f800
commit 624664c4d7
6 changed files with 69 additions and 44 deletions

View File

@ -7,7 +7,7 @@
<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="">{% if heightweight_id %}Edit{% else %}Add{% endif %} height/weight couple</h4>
<h4 class="">{% if heightweight_id %}Edit{% else %}Add{% endif %} height/weight</h4>
</div>
<div class="card-body">
{% if form.errors %}
@ -21,7 +21,7 @@
{% csrf_token %}
<div class="form-group row ">
<label for="id_gymnast" class="col-3 col-sm-2 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></label>
<label for="id_gymnast" class="col-3 col-sm-3 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></label>
<div
class="col-9 col-sm-9 col-md-9 col-lg-6 col-lg-8 col-xl-8 {% if form.jumper.errors %}has-danger{% endif %}">
{% if request.user|has_group:"trainer" %}
@ -36,34 +36,34 @@
</div>
<div class="form-group row ">
<label for="id_date" class="col-3 col-sm-2 col-form-label">Date <span
<label for="id_date" class="col-3 col-sm-3 col-form-label">Date <span
class="text-danger"><b>*</b></span></label>
<div class="col-6 col-sm-3 col-md-5 col-lg-4 col-xl-3 {% if form.date.errors %}has-danger{% endif %}">
<div class="col-6 col-sm-3 col-md-4 col-lg-4 col-xl-3 {% if form.date.errors %}has-danger{% endif %}">
{{ form.date }}
{% if form.date.errors %}<span class="btn btn-sm btn-danger-outline">{% for error in form.date.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_height" class="col-3 col-sm-2 col-form-label">Height <span
<label for="id_height" class="col-3 col-sm-3 col-form-label">Height <span
class="text-danger"><b>*</b></span></label>
<div class="col-6 col-sm-3 col-md-3 col-lg-3 {% if form.height.errors %}has-danger{% endif %}">
<div class="col-4 col-sm-3 col-md-3 col-lg-3 {% if form.height.errors %}has-danger{% endif %}">
{{ form.height }}
{% if form.height.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.height.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_hips_height" class="col-3 col-sm-2 col-form-label">Hips Height</label>
<label for="id_hips_height" class="col-3 col-sm-3 col-form-label">Hips Height</label>
<div
class="col-6 col-sm-3 col-md-3 col-lg-3 {% if form.hips_height.errors %}has-danger{% endif %}">
class="col-4 col-sm-3 col-md-3 col-lg-3 {% if form.hips_height.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 %}
</div>
</div>
<div class="form-group row ">
<label for="id_weight" class="col-3 col-sm-2 col-form-label">Weight <span
<label for="id_weight" class="col-3 col-sm-3 col-form-label">Weight <span
class="text-danger"><b>*</b></span></label>
<div class="col-6 col-sm-3 col-md-3 col-lg-3 {% if form.weight.errors %}has-danger{% endif %}">
<div class="col-4 col-sm-3 col-md-3 col-lg-3 {% if form.weight.errors %}has-danger{% endif %}">
{{ form.weight }}
{% if form.weight.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.weight.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>

View File

@ -6,10 +6,10 @@
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="card">
<div class="card-header row">
<div class="col-8">
<div class="col-10 pr-0">
<h4 class="">Height/Weight list {% if gymnast %}for <a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}"><i>{{ gymnast }}</i></a>{% endif %}</h4>
</div>
<div class="col-1 ml-auto">
<div class="col-2 ml-auto pl-0">
<div class="text-right">
{% if request.user|has_group:"trainer" %}
<a href="{% if gymnast %}{% url 'heightweight_create_for_gymnast' gymnast.id %}{% else %}{% url 'heightweight_create' %}{% endif %}">
@ -21,18 +21,20 @@
</div>
</div>
</div>
<div class="card-body">
<div class="card-body pt-1">
{% if heightweight_list %}
<table class="table tablesorter table-striped mb-0" data-sort="table" id="heightweight_table">
<thead>
<tr>
<th></th>
<th class="header text-left">Date</th>
{% if not gymnast %}
<th class="header text-left">Gymnast</th>
<th class="header text-left">Height</th>
<th class="header text-left">Hips height</th>
<th class="header text-left">Weight</th>
<th class="header text-left">BMI</th>
{% endif %}
<th class="header text-center">Height</th>
<th class="header text-center">Hips height</th>
<th class="header text-center">Weight</th>
<th class="header text-center">BMI</th>
</tr>
</thead>
<tbody>
@ -43,12 +45,14 @@
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-left">{{ heightweight.date | date:"d-m-Y" }}</td>
<td class="text-left">{{ heightweight.date | date:"j-n-Y" }}</td>
{% if not gymnast %}
<td class="text-left"><a href="{% url 'gymnast_details' heightweight.gymnast.id %}">{{ heightweight.gymnast }}</a></td>
<td>{{ heightweight.height }}</td>
<td>{% if heightweight.hips_height == None %}-{% else %}{{ heightweight.hips_height }}{% endif %}</td>
<td>{{ heightweight.weight }}</td>
<td>
{% endif %}
<td class="text-right">{{ heightweight.height }}</td>
<td class="text-right">{% if heightweight.hips_height == None %}-{% else %}{{ heightweight.hips_height }}{% endif %}</td>
<td class="text-right">{{ heightweight.weight }}</td>
<td class="text-right">
{% if gymnast %}
{% if gymnast.gender == 0 %}
{% if heightweight.bmi < 19 %}

View File

@ -14,7 +14,7 @@
{% csrf_token %}
<div class="form-group row ">
<label for="id_gymnast" class="col-4 col-sm-2 col-md-4 col-lg-4 col-xl-3 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></label>
<div class="col-8 col-sm-9 col-md-9 col-lg-6 col-lg-8 col-xl-8 {% if form.jumper.errors %}has-danger{% endif %}">
<div class="col-8 col-sm-10 col-md-8 col-lg-8 col-lg-8 col-xl-9 {% if form.jumper.errors %}has-danger{% endif %}">
{% if request.user|has_group:"trainer" %}
{{ form.gymnast }}
{{ form.gymnast_related }}
@ -31,7 +31,7 @@
</div>
<div class="form-group row ">
<label for="id_date" class="col-4 col-sm-2 col-md-4 col-lg-4 col-xl-3 col-form-label">Date <span class="text-danger"><b>*</b></span></label>
<div class="col-5 col-sm-3 col-md-3 col-lg-4 col-xl-3 {% if form.date.errors %}has-danger{% endif %}">
<div class="col-5 col-sm-3 col-md-4 col-lg-4 col-xl-3 {% if form.date.errors %}has-danger{% endif %}">
{{ form.date }}
{% if form.date.errors %}<span class="btn btn-sm btn-danger-outline">{% for error in form.date.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
@ -54,8 +54,8 @@
{{ form.mindstate }}
{% if form.mindstate.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.mindstate.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Bad - 10: Very Good)</p>
<div class="col-4 col-sm-3 col-md-5 col-lg-5 pl-0 pr-0">
<p class="text-muted text-form-info mb-0 mt-2">(1: Very Bad - 10: Very Good)</p>
</div>
</div>
<div class="form-group row ">
@ -64,8 +64,8 @@
{{ form.sleep }}
{% if form.sleep.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.sleep.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Bad - 10: Very Good)</p>
<div class="col-4 col-sm-3 col-md-5 col-lg-5 pl-0 pr-0">
<p class="text-muted text-form-info mb-0 mt-2">(1: Very Bad - 10: Very Good)</p>
</div>
</div>
<div class="form-group row ">
@ -74,8 +74,8 @@
{{ form.stress }}
{% if form.stress.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.stress.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Low - 10: Very High)</p>
<div class="col-4 col-sm-3 col-md-5 col-lg-5 pl-0 pr-0">
<p class="text-muted text-form-info mb-0 mt-2">(1: Very Low - 10: Very High)</p>
</div>
</div>
<div class="form-group row ">
@ -84,8 +84,8 @@
{{ form.fatigue }}
{% if form.fatigue.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.fatigue.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Low - 10: Very High)</p>
<div class="col-4 col-sm-3 col-md-5 col-lg-5 pl-0 pr-0">
<p class="text-muted text-form-info mb-0 mt-2">(1: Very Low - 10: Very High)</p>
</div>
</div>
<div class="form-group row ">
@ -94,8 +94,8 @@
{{ form.muscle_soreness }}
{% if form.muscle_soreness.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.muscle_soreness.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
<div class="col-4 col-sm-3 col-md-5 col-lg-5">
<p class="text-muted">(1: Very Low - 10: Very High)</p>
<div class="col-4 col-sm-3 col-md-5 col-lg-5 pl-0 pr-0">
<p class="text-muted text-form-info mb-0 mt-2">(1: Very Low - 10: Very High)</p>
</div>
</div>
<div class="form-group row">

View File

@ -6,10 +6,10 @@
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="card">
<div class="card-header row">
<div class="col-8">
<div class="col-10 pr-0">
<h4 class="">Well being list {% if gymnast %}for <a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}"><i>{{ gymnast }}</i></a>{% endif %}</h4>
</div>
<div class="col-1 ml-auto">
<div class="col-2 ml-auto pl-0">
<div class="text-right">
{% if request.user|has_group:"trainer" %}
<a href="{% if gymnast %}{% url 'wellbeing_create_for_gymnast' gymnast.id %}{% else %}{% url 'wellbeing_create' %}{% endif %}">
@ -28,7 +28,9 @@
<tr>
<th></th>
<th class="header text-left">Date</th>
{% if not gymnast %}
<th class="header text-left">Gymnast</th>
{% endif %}
<th class="header text-center">Mindstate</th>
<th class="header text-center">Sleep</th>
<th class="header text-center">Stress</th>
@ -44,10 +46,16 @@
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-left"><a href="{% url 'wellbeing_details' wellbeing.id %}">{{ wellbeing.date | date:"d-m-Y" }}</a></td>
<td class="text-left">
<a href="{% url 'wellbeing_details' wellbeing.id %}">{{ wellbeing.date | date:"j-n-Y" }}</a>
</td>
{% if not gymnast %}
<td class="text-left">
<a href="{% url 'gymnast_details_tab' wellbeing.gymnast.id 'physiological' %}">
{{ wellbeing.gymnast }}</td>
{{ wellbeing.gymnast }}
</a>
</td>
{% endif %}
<td class="text-right">
{% if wellbeing.mindstate < 5%}<b><span class="text-danger">{% endif %}
{{ wellbeing.mindstate }}

View File

@ -260,11 +260,16 @@ def gymnast_display_physiological(request, gymnast_id):
Args:
gymnast_id (int) identifiant du gymnast
"""
injuries_list = Injury.objects.filter(gymnast=gymnast_id).order_by("date")
wellbeing_list = WellBeing.objects.filter(gymnast=gymnast_id).order_by("date")
height_weight_list = HeightWeight.objects.filter(gymnast=gymnast_id).order_by(
"date"
)
start_date = pendulum.now().date().subtract(months=6)
injuries_list = Injury.objects.filter(
gymnast=gymnast_id, date__gte=start_date
).order_by("date")
wellbeing_list = WellBeing.objects.filter(
gymnast=gymnast_id, date__gte=start_date
).order_by("date")
height_weight_list = HeightWeight.objects.filter(
gymnast=gymnast_id, date__gte=start_date
).order_by("date")
context = {
"injuries_list": injuries_list,
@ -286,8 +291,11 @@ def gymnast_display_scores_chrono(request, gymnast_id):
Args:
gymnast_id (int) identifiant du gymnast
"""
start_date = pendulum.now().date().subtract(months=6)
score_list = Point.objects.filter(gymnast=gymnast_id).order_by("-event__date_begin")
chrono_list = Chrono.objects.filter(gymnast=gymnast_id).order_by("date")
chrono_list = Chrono.objects.filter(
gymnast=gymnast_id, date__gte=start_date
).order_by("date")
base_queryset = chrono_list.values("date").annotate(score_avg=Avg("tof"))
context = {

View File

@ -90,6 +90,11 @@ textarea.form-control {
color: #0CA3E0 !important;
}
.text-form-info {
font-weight: lighter !important;
font-size: 12px;
}
.progress-bar-primary {
background: #ba54f5;
background-image: -webkit-linear-gradient(to bottom left, #ba54f5, #e14eca, #ba54f5);