Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Move the exercised musces from sidebar to main area

Roland Geider653eb547eb55
diff --git a/wger/exercises/templates/view.html b/wger/exercises/templates/view.html
index b205012c4..e70820375 100644
--- a/wger/exercises/templates/view.html
+++ b/wger/exercises/templates/view.html
@@ -82,7 +82,7 @@ the search.{% endblocktrans %}
{% with comments=exercise.exercisecomment_set.all %}
{% if comments %}
-<h3>{% trans "Comments for this exercise" %}</h3>
+<h4>{% trans "Comments for this exercise" %}</h4>
<ul>
{% for comment in comments %}
@@ -128,46 +128,6 @@ the search.{% endblocktrans %}
{% endif %}
-{% if logs %}
-
-<h3>{% trans "Weight log" %}</h3>
-
-{% render_weight_log logs svg_uuid %}
-<script src="{% static 'js/d3.js' %}"></script>
-<script src="{% static 'js/jquery-globalize/lib/globalize.js' %}"></script>
-
-<script>
-$(document).ready(function() {
-weight_log_chart({{json|safe}}, "{{svg_uuid}}", "{{reps}}")
-});
-</script>
-
-
-
-{% endif %}
-
-{% endblock %}
-
-
-<!--
- Side bar
--->
-{% block sidebar %}
-
-<h3>{% trans "Back to overview" %}</h3>
-<p>
- <a href="{% url 'wger.exercises.views.exercises.overview' %}">
- <img src="{% static 'images/icons/list.svg' %}"
- width="32"
- height="32"
- alt="{% trans 'Back to overview' %}"
- >
- {% trans "Back to exercise overview" %}
- </a>
-</p>
-
-
-
{% with muscles=exercise.muscles.all %}
{% with muscles_secondary=exercise.muscles_secondary.all %}
@@ -183,23 +143,16 @@ weight_log_chart({{json|safe}}, "{{svg_uuid}}", "{{reps}}")
{% trans "Main muscles" %}
</div>
-{% if muscles_secondary %}
<div>
<div style="width:1em;height:1em;background-color:#f57900;float:left;margin-right:0.5em;"></div>
{% trans "Secondary muscles" %}
</div>
-{% endif %}
-{% if muscle_backgrounds_front %}
<div class="ym-grid linearize-level-1">
<div class="ym-g50 ym-gl">
<div class="ym-gbox-left">
<div id="muscle-front" class="muscle-background" style="background-image: {% for background in muscle_backgrounds_front %}url({% static background %}){% if not forloop.last %},{% endif %}{% endfor %};">
</div>
- </div>
- </div>
- <div class="ym-g40 ym-gr">
- <div class="ym-gbox-right">
<ul>
{% for muscle in muscles %}
{% if muscle.is_front %}
@@ -215,41 +168,67 @@ weight_log_chart({{json|safe}}, "{{svg_uuid}}", "{{reps}}")
</ul>
</div>
</div>
-</div>
-{% endif %}
-
-
-{% if muscle_backgrounds_back %}
-<div class="ym-grid linearize-level-1">
- <div class="ym-g50 ym-gl">
- <div class="ym-gbox-left">
- <div id="muscle-front" class="muscle-background" style="background-image: {% for background in muscle_backgrounds_back %}url({% static background %}){% if not forloop.last %},{% endif %}{% endfor %};">
- </div>
- </div>
- </div>
- <div class="ym-g40 ym-gr">
+ <div class="ym-g50 ym-gr">
<div class="ym-gbox-right">
- <ul>
- {% for muscle in muscles %}
- {% if not muscle.is_front %}
- <li>{{muscle.name}}</li>
- {% endif %}
- {% endfor %}
+ <div id="muscle-front" class="muscle-background" style="background-image: {% for background in muscle_backgrounds_back %}url({% static background %}){% if not forloop.last %},{% endif %}{% endfor %};">
+ </div>
+ <ul>
+ {% for muscle in muscles %}
+ {% if not muscle.is_front %}
+ <li>{{muscle.name}}</li>
+ {% endif %}
+ {% endfor %}
- {% for muscle in muscles_secondary %}
- {% if not muscle.is_front %}
- <li>{{muscle.name}}</li>
- {% endif %}
- {% endfor %}
- </ul>
+ {% for muscle in muscles_secondary %}
+ {% if not muscle.is_front %}
+ <li>{{muscle.name}}</li>
+ {% endif %}
+ {% endfor %}
+ </ul>
</div>
</div>
</div>
-{% endif %}
+
{% endif %}
{% endwith %}
-{% endwith %}
+{% endwith %} {# end musclelist #}
+
+
+{% if logs %}
+<h3>{% trans "Weight log" %}</h3>
+
+{% render_weight_log logs svg_uuid %}
+<script src="{% static 'js/d3.js' %}"></script>
+<script src="{% static 'js/jquery-globalize/lib/globalize.js' %}"></script>
+
+<script>
+$(document).ready(function() {
+weight_log_chart({{json|safe}}, "{{svg_uuid}}", "{{reps}}")
+});
+</script>
+{% endif %}
+
+{% endblock %}
+
+
+<!--
+ Side bar
+-->
+{% block sidebar %}
+
+<h3>{% trans "Back to overview" %}</h3>
+<p>
+ <a href="{% url 'wger.exercises.views.exercises.overview' %}">
+ <img src="{% static 'images/icons/list.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Back to overview' %}"
+ >
+ {% trans "Back to exercise overview" %}
+ </a>
+</p>
+<hr>
{% if exercise.status == EXERCISE_STATUS_ACCEPTED %}
<div class="alert" style="margin-top:1em;">
@@ -258,6 +237,7 @@ weight_log_chart({{json|safe}}, "{{svg_uuid}}", "{{reps}}")
<p>{% blocktrans %}This exercise was submitted by <strong>{{username}}</strong>.{% endblocktrans %}
{% endwith %}
</div>
+<hr>
{% endif %}
{% if perms.exercises %}
@@ -281,6 +261,7 @@ weight_log_chart({{json|safe}}, "{{svg_uuid}}", "{{reps}}")
{% trans "Delete" %}
</a>
</p>
+<hr>
{% endif %}
{% cc_by_sa_sidebar language %}
diff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.py
index 89ce734ff..5b47002d9 100644
--- a/wger/exercises/views/exercises.py
+++ b/wger/exercises/views/exercises.py
@@ -120,24 +120,19 @@ def view(request, id, slug=None):
# Append the "main" background, with the silhouette of the human body
# This has to happen as the last step, so it is rendered behind the muscles.
- if backgrounds_front:
- backgrounds_front.append('images/muscles/muscular_system_front.svg')
-
- if backgrounds_back:
- backgrounds_back.append('images/muscles/muscular_system_back.svg')
+ backgrounds_front.append('images/muscles/muscular_system_front.svg')
+ backgrounds_back.append('images/muscles/muscular_system_back.svg')
template_data['muscle_backgrounds_front'] = backgrounds_front
template_data['muscle_backgrounds_back'] = backgrounds_back
# If the user is logged in, load the log and prepare the entries for
# rendering in the D3 chart
- entry = WorkoutLog()
entry_log = []
chart_data = []
if request.user.is_authenticated():
- logs = WorkoutLog.objects.filter(user=request.user,
- exercise=exercise)
-
+ entry = WorkoutLog()
+ logs = WorkoutLog.objects.filter(user=request.user, exercise=exercise)
entry_log, chart_data = entry.process_log_entries(logs)
template_data['logs'] = entry_log