Highlight equipments used in session + number of rounds
This commit is contained in:
parent
daa8a23bd0
commit
2f83234230
4 changed files with 27 additions and 2 deletions
|
@ -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 @@
|
|||
<ul class="list-group">
|
||||
{% for equipment in session.room.equipments.all %}
|
||||
<a href="{% url 'equipment-detail' equipment.pk %}"
|
||||
class="list-group-item list-group-item-action">{{ equipment.name }}</a>
|
||||
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 %}
|
||||
<span class="badge badge-success badge-pill">{{ used_equipments|get_item:equipment }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -41,7 +50,8 @@
|
|||
{% for round in session.rounds.all %}
|
||||
<a href="{% url 'round-edit' round.pk %}"
|
||||
class="list-group-item list-group-item-action">{{ round.equipment.name }}
|
||||
– {{ round.repetition_number }} répétitions × {{ round.chosen_weight }} {{ round.equipment.unit }}</a>
|
||||
– {{ round.repetition_number }} répétitions
|
||||
× {{ round.chosen_weight }} {{ round.equipment.unit }}</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
|
|
0
gym/templatetags/__init__.py
Normal file
0
gym/templatetags/__init__.py
Normal file
6
gym/templatetags/custom_filters.py
Normal file
6
gym/templatetags/custom_filters.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.template.defaulttags import register
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_item(dictionary, key):
|
||||
return dictionary.get(key)
|
|
@ -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 [
|
||||
|
|
Loading…
Reference in a new issue