Display real percentage of the round

This commit is contained in:
Gabriel Augendre 2019-06-23 16:06:52 +02:00
parent 65d604de15
commit 2c499addfa
3 changed files with 17 additions and 3 deletions

View file

@ -165,3 +165,12 @@ class Round(models.Model):
null=True, null=True,
) )
notes = models.TextField("notes", blank=True) notes = models.TextField("notes", blank=True)
@property
def real_percentage(self):
theoretical_max = (
self.equipment.theoretical_maxs.filter(date__lte=self.session.start)
.order_by("-date")
.first()
)
return self.chosen_weight / theoretical_max.value * 100

View file

@ -2,7 +2,10 @@
{% load humanize %} {% load humanize %}
{% block title %}{{ equipment.name }} ({{ equipment.room.name }}){% endblock %} {% block title %}{{ equipment.name }} ({{ equipment.room.name }}){% endblock %}
{% block h1 %}{{ equipment.name }} <small class="text-muted">({{ equipment.room.name }})</small>{% endblock %} {% block h1 %}
{{ equipment.name }}
<small class="text-muted">({{ equipment.room.name }})</small>
{% endblock %}
{% block content %} {% block content %}
@ -49,7 +52,8 @@
{% for round in rounds %} {% for round in rounds %}
<a href="{% url 'round-edit' round.pk %}" <a href="{% url 'round-edit' round.pk %}"
class="list-group-item list-group-item-action">{{ round.repetition_number }} répétitions class="list-group-item list-group-item-action">{{ round.repetition_number }} répétitions
&times; {{ round.chosen_weight }} {{ equipment.unit }}</a> &times; {{ round.chosen_weight }} {{ equipment.unit }}
({{ round.theoretical_max_percentage }}% -> {{ round.real_percentage }}%)</a>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}

View file

@ -51,7 +51,8 @@
<a href="{% url 'round-edit' round.pk %}" <a href="{% url 'round-edit' round.pk %}"
class="list-group-item list-group-item-action">{{ round.equipment.name }} class="list-group-item list-group-item-action">{{ round.equipment.name }}
&ndash; {{ round.repetition_number }} répétitions &ndash; {{ round.repetition_number }} répétitions
&times; {{ round.chosen_weight }} {{ round.equipment.unit }}</a> &times; {{ round.chosen_weight }} {{ round.equipment.unit }}
({{ round.theoretical_max_percentage }}% -> {{ round.real_percentage }}%)</a>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}