Display rounds for current machine if session in progress
This commit is contained in:
parent
84e8f76c67
commit
89af0e40c0
2 changed files with 27 additions and 1 deletions
|
@ -56,4 +56,21 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if session %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h2>Séries de la séance en cours</h2>
|
||||||
|
{% if rounds %}
|
||||||
|
<ul class="list-group">
|
||||||
|
{% for round in rounds %}
|
||||||
|
<a href="#" class="list-group-item">{{ round.repetition_number }} répétitions
|
||||||
|
× {{ round.chosen_weight }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>Pas de série pour cette machine aujourd'hui.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
11
gym/views.py
11
gym/views.py
|
@ -40,10 +40,19 @@ class EquipmentDetailView(generic.DetailView):
|
||||||
model = Equipment
|
model = Equipment
|
||||||
context_object_name = 'equipment'
|
context_object_name = 'equipment'
|
||||||
template_name = 'gym/equipment.html'
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**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
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue