diff --git a/gym/templates/gym/equipment.html b/gym/templates/gym/equipment.html index c4d5563..531c3e9 100644 --- a/gym/templates/gym/equipment.html +++ b/gym/templates/gym/equipment.html @@ -56,4 +56,21 @@ {% endif %} + {% if session %} +
+
+

Séries de la séance en cours

+ {% if rounds %} + + {% else %} +

Pas de série pour cette machine aujourd'hui.

+ {% endif %} +
+
+ {% endif %} {% endblock %} \ No newline at end of file diff --git a/gym/views.py b/gym/views.py index 249eada..9936b3e 100644 --- a/gym/views.py +++ b/gym/views.py @@ -40,10 +40,19 @@ class EquipmentDetailView(generic.DetailView): model = Equipment context_object_name = 'equipment' template_name = 'gym/equipment.html' + session = None + + def dispatch(self, request, *args, **kwargs): + session_pk = self.request.session.get('session_pk') + if session_pk: + self.session = Session.objects.get(pk=session_pk) + return super().dispatch(request, *args, **kwargs) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context['session'] = self.request.session.get('session_pk') + if self.session: + context['session'] = self.session.pk + context['rounds'] = Round.objects.filter(session=self.session, equipment=self.get_object()) return context