Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add an additional list with weights grouped by reps for D3 chart

Roland Geiderac41ea83080d
diff --git a/manager/templates/workout/log.html b/manager/templates/workout/log.html
index 88c088853..b39d0c7c4 100644
--- a/manager/templates/workout/log.html
+++ b/manager/templates/workout/log.html
@@ -6,6 +6,7 @@
{% block title %}{% trans "Weight log for workout" %} – {{ workout.creation_date }}{% endblock %}
{% block header %}
+<script src="{% static 'js/d3.js' %}"></script>
{% endblock %}
{% block content %}
@@ -19,7 +20,6 @@
</p>
{% endif %}
-
{% for day, exercise_log in workout_log.items %}
<h3>{{ day.description }}</h3>
@@ -37,30 +37,37 @@
{% for exercise, date_list in exercise_log.items %}
<p><a href="{{ exercise.get_absolute_url }}">{{ exercise.name }}</a></p>
- {% if date_list.items %}
+ {% if date_list.log_by_date %}
<div style="overflow-x: auto;">
<table class="noborder" style="border: 0 none; width: 7.5em;">
<tr>
- {% for date, entry_list in date_list.items %}
+ {% with list=date_list.log_by_date %}
+ {% for date, entry_list in list.items %}
<td style="padding: 0em; border-top-width: 0px;">
<table class="narrow" style="width: 7.5em;">
<tr>
<th>{{date|date:"d.m.Y"}}</th>
</tr>
{% for entry in entry_list %}
- <tr>
- <td>{{entry.reps}} {% trans "Reps" %} × {{entry.weight}}</td>
- </tr>
+ <tr>
+ <td>{{entry.reps}} {% trans "Reps" %} × {{entry.weight}}</td>
+ </tr>
{% endfor %}
</table>
</td>
{% endfor %}
+ {% endwith %}
</tr>
</table>
</div>
{% else %}
<p><em>{% trans "No weight entries here." %}</em></p>
{% endif %}
+
+ {% with list=date_list.log_by_reps %}
+
+ {% endwith %}
+
{% empty%}
<p>
<em>{% trans "No exercises for this day." %}</em>
diff --git a/manager/views.py b/manager/views.py
index d56e53343..8648f0cb6 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -1115,11 +1115,11 @@ class WorkoutLogDetailView(DetailView):
logger.debug(entry_log_by_reps)
if entry_log:
exercise_log[exercise].append(entry_log)
- else:
- logger.debug('entry log empty for exercise %s' % exercise)
if exercise_log:
- workout_log[day][exercise] = entry_log
+ workout_log[day][exercise] = {}
+ workout_log[day][exercise]['log_by_date'] = entry_log
+ workout_log[day][exercise]['log_by_reps'] = entry_log_by_reps
context['workout_log'] = workout_log
#logger.debug(workout_log)