Add BMI into heightweith model

This commit is contained in:
Gregory Trullemans 2023-11-21 09:10:28 +01:00
parent e5970da66d
commit 60002cfdeb
3 changed files with 11 additions and 5 deletions

View File

@ -511,6 +511,10 @@ class HeightWeight(Seasonisable):
)
weight = models.DecimalField(max_digits=4, decimal_places=1, verbose_name="Weight")
@property
def bmi(self):
return self.weight / (self.height * self.height)
def __str__(self):
return f"{self.gymnast} : {self.height}/{self.hips_height} - {self.weight}"

View File

@ -32,6 +32,7 @@
<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>
</tr>
</thead>
<tbody>
@ -47,6 +48,7 @@
<td>{{ heightweight.height }}</td>
<td>{{ heightweight.hips_height }}</td>
<td>{{ heightweight.weight }}</td>
<td>{{ heightweight.bmi }}</td>
</tr>
{% endfor %}
</tbody>
@ -77,7 +79,7 @@
paging: false,
searching: false,
ordering: false,
// "bInfo" : false,
"bInfo" : false,
});
});
</script>

View File

@ -1100,16 +1100,16 @@ def heightweight_create_or_update(request, heightweight_id=None, gymnast_id=None
send_mail(
f"{gymnast} : Nouveau poids/taille enregistré",
f"Un nouveau poids/taille enregistré pour {gymnast} ({date}) : {height}cm / {weight}kg (BMI: {bmi}).",
f"Un nouveau poids/taille enregistré pour {gymnast} ({date}) : {height} cm / {weight} kg (BMI: {bmi}).",
settings.EMAIL_HOST_USER,
receiver,
fail_silently=False,
html_message=f"""<p>Bonjour,</p>
<p>Un nouveau poids/taille enregistré pour {gymnast} pour le {date.strftime('%d %B %Y')} :</p>
<ul>
<li>{height}cm</li>
<li>{weight}kg</li>
<li>BMI : {bmi}</li>
<li>Height: {height} cm</li>
<li>Weight: {weight} kg</li>
<li>BMI: {bmi}</li>
</ul>
<br />
<p>Excellente journée</p>