Adding Hips Height in followup
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Gregory Trullemans 2021-12-22 14:47:00 +01:00
parent 5991ec221a
commit 7ff74c743b
10 changed files with 50 additions and 13 deletions

View File

@ -30,11 +30,18 @@
<label for="id_height" class="col-4 col-sm-3 col-form-label">Height *</label>
<div class="col-8 col-sm-4 col-md-3 col-lg-2 {% if form.type.errors %}has-danger{% endif %}">
{{ form.height }}
{% if form.height.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.skill.errors %}{{error}}{% endfor %}</span>{% endif %}
{% 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_type" class="col-4 col-sm-3 col-form-label">Weight *</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 %}
</div>
</div>
<div class="form-group row ">
<label for="id_weight" class="col-4 col-sm-3 col-form-label">Weight *</label>
<div class="col-8 col-sm-4 col-md-3 col-lg-2 {% if form.type.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 %}

View File

@ -16,6 +16,7 @@
<th class="header text-left">Date</th>
<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>
</tr>
</thead>
@ -30,6 +31,7 @@
<td class="text-left">{{ heightweight.date | date:"d-m-Y" }}</td>
<td class="text-left"><a href="{% url 'gymnast_details' heightweight.gymnast.id %}">{{ heightweight.gymnast }}</a></td>
<td>{{ heightweight.height }}</td>
<td>{{ heightweight.hips_height }}</td>
<td>{{ heightweight.weight }}</td>
</tr>
{% endfor %}

View File

@ -41,7 +41,7 @@
</table>
{% else %}
<p>There are no routines corresponding to your criterias</p>
<p class="text-muted">There are no routines associated to this gymnast.</p>
{% endif %}
</div>
<div class="card-footer text-right text-muted pt-0">

View File

@ -95,9 +95,7 @@
</div>
{% else %}
<div class="card-body pt-0 pb-0">
<p>No score recorded for this gymnast.</p>
</div>
<p class="pl-3 text-muted">No score recorded for this gymnast.</p>
{% endif %}
<div class="card-footer text-right text-muted pt-0">
<a href="{% url 'score_list_for_gymnast' gymnast_id %}">
@ -169,7 +167,7 @@
});
</script> -->
{% else %}
<p>No chrono recorded for this gymnast.</p>
<p class="pl-3 text-muted">No chrono recorded for this gymnast.</p>
{% endif %}
</div>
<div class="card-footer text-right text-muted pt-0">

View File

@ -10,7 +10,7 @@
<canvas id="chartjs_height_weight_state" class="chartjs" width="400" height="200"></canvas>
</div>
{% else %}
<p>No height/weight recorded for this gymnast.</p>
<p class="pl-3 text-muted">No height/weight recorded for this gymnast.</p>
{% endif %}
</div>
<div class="card-footer text-right text-muted pt-0">
@ -39,7 +39,7 @@
<canvas id="chartjs_mindstate" class="chartjs" width="400" height="200"></canvas>
</div>
{% else %}
<p>No mindstate recorded for this gymnast.</p>
<p class="pl-3 text-muted">No mindstate recorded for this gymnast.</p>
{% endif %}
</div>
<div class="card-footer text-right text-muted pt-0">

View File

@ -92,7 +92,7 @@ class NumberOfRoutineDoneAdmin(ForeignKeyAutocompleteAdmin):
class HeightWeightAdmin(ForeignKeyAutocompleteAdmin):
model = HeightWeight
list_display = ("gymnast", "height", "weight", "date")
list_display = ("gymnast", "height", "hips_height", "weight", "date")
list_filter = ("gymnast",)

View File

@ -308,7 +308,7 @@ class HeightWeightForm(forms.ModelForm):
class Meta:
model = HeightWeight
fields = ("gymnast", "date", "height", "weight")
fields = ("gymnast", "date", "height", "hips_height", "weight")
widgets = {
"gymnast": forms.HiddenInput(),
"date": forms.TextInput(
@ -321,6 +321,9 @@ class HeightWeightForm(forms.ModelForm):
"height": forms.NumberInput(
attrs={"class": "form-control", "placeholder": "xxx,x"}
),
"hips_height": forms.NumberInput(
attrs={"class": "form-control", "placeholder": "xxx,x"}
),
"weight": forms.NumberInput(
attrs={"class": "form-control", "placeholder": "xxx,x"}
),

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.8 on 2021-12-22 13:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('people', '0001_initial'),
('followup', '0008_alter_learnedskill_unique_together'),
]
operations = [
migrations.AddField(
model_name='heightweight',
name='hips_height',
field=models.DecimalField(decimal_places=1, default=100, max_digits=4, verbose_name='Hips height'),
preserve_default=False,
),
migrations.AlterUniqueTogether(
name='heightweight',
unique_together={('gymnast', 'date')},
),
]

View File

@ -276,6 +276,7 @@ class HeightWeight(models.Model):
class Meta:
verbose_name = "Height & weight"
verbose_name_plural = "Heights & weights"
unique_together = ("gymnast", "date")
gymnast = models.ForeignKey(
Gymnast,
@ -284,8 +285,9 @@ class HeightWeight(models.Model):
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")
weight = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Weight")
date = models.DateField(default=date.today, verbose_name="Date")
def __str__(self):
return "%s : %s - %s" % (self.gymnast, self.height, self.weight)
return "%s : %s/%s - %s" % (self.gymnast, self.height, self.hips_height, self.weight)

View File

@ -364,9 +364,10 @@ def heightweight_create_or_update(request, heightweight_id=None, gymnast_id=None
heightweight = get_object_or_404(HeightWeight, pk=heightweight_id)
data = {"gymnast_related": heightweight.gymnast}
else:
heightweight = None
data = {}
if gymnast_id:
heightweight = HeightWeight.objects.filter(gymnast=gymnast_id).last()
heightweight = HeightWeight.objects.filter(gymnast=gymnast_id).order_by('-date').first()
gymnast = get_object_or_404(Gymnast, pk=gymnast_id)
data["gymnast"] = gymnast_id
data["gymnast_related"] = str(gymnast)