diff --git a/gym/templates/gym/session_detail.html b/gym/templates/gym/session_detail.html
index 633aca7..223fc45 100644
--- a/gym/templates/gym/session_detail.html
+++ b/gym/templates/gym/session_detail.html
@@ -1,5 +1,6 @@
{% extends 'gym/base.html' %}
{% load bootstrap4 %}
+{% load custom_filters %}
{% block title %}Séance en cours{% endblock %}
{% block h1 %}Séance en cours{% endblock %}
@@ -28,7 +29,15 @@
{% for equipment in session.room.equipments.all %}
{{ equipment.name }}
+ class="list-group-item
+ list-group-item-action
+ {% if equipment in used_equipments %}list-group-item-success{% endif %}
+ d-flex justify-content-between align-items-center">
+ {{ equipment.name }}
+ {% if equipment in used_equipments %}
+ {{ used_equipments|get_item:equipment }}
+ {% endif %}
+
{% endfor %}
@@ -41,7 +50,8 @@
{% for round in session.rounds.all %}
{{ round.equipment.name }}
- – {{ round.repetition_number }} répétitions × {{ round.chosen_weight }} {{ round.equipment.unit }}
+ – {{ round.repetition_number }} répétitions
+ × {{ round.chosen_weight }} {{ round.equipment.unit }}
{% endfor %}
{% else %}
diff --git a/gym/templatetags/__init__.py b/gym/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/gym/templatetags/custom_filters.py b/gym/templatetags/custom_filters.py
new file mode 100644
index 0000000..181fd01
--- /dev/null
+++ b/gym/templatetags/custom_filters.py
@@ -0,0 +1,6 @@
+from django.template.defaulttags import register
+
+
+@register.filter
+def get_item(dictionary, key):
+ return dictionary.get(key)
diff --git a/gym/views.py b/gym/views.py
index 51b0dcb..53806b7 100644
--- a/gym/views.py
+++ b/gym/views.py
@@ -389,6 +389,15 @@ class SessionDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailVie
context_object_name = 'session'
template_name = 'gym/session_detail.html'
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ session = self.get_object()
+
+ context['used_equipments'] = {k: Round.objects.filter(equipment=k, session=session).count()
+ for k in Equipment.objects.filter(rounds__session=self.get_object())}
+
+ return context
+
def get_quick_actions(self):
room_pk = self.get_object().room.pk
return [