Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Always workout and nutrition plan tables on dashboard

Roland Geiderf749db73b14d
diff --git a/wger/core/templates/index.html b/wger/core/templates/index.html
index 71d6f6d91..c42490271 100644
--- a/wger/core/templates/index.html
+++ b/wger/core/templates/index.html
@@ -37,19 +37,20 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
<div class="row">
<div class="col-sm-4">
<h4>{% trans "Workout"%}</h4>
- {% if current_workout %}
- <p>
- <a href="{{ current_workout.get_absolute_url }}">
- {% if current_workout.comment %}
- {{ current_workout.comment }}
- {% else %}
- {% trans "Workout" %}
- {% endif %}
- </a>
- </p>
- <p>
- – {{ current_workout.creation_date }}
- <p>
+ {% if current_workout %}
+ <p>
+ <a href="{{ current_workout.get_absolute_url }}">
+ {% if current_workout.comment %}
+ {{ current_workout.comment }}
+ {% else %}
+ {% trans "Workout" %}
+ {% endif %}
+ </a>
+ </p>
+ <p>
+ – {{ current_workout.creation_date }}
+ <p>
+ {% endif %}
<table class="table table-hover table-condensed">
{% for day, exercise, is_workout in weekdays %}
@@ -65,7 +66,6 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
</tr>
{% endfor %}
</table>
- {% endif %}
</div>
<div class="col-sm-4">
<h4>{% trans "Nutrition plan"%}</h4>
@@ -77,33 +77,33 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
<p>
– {{ plan.creation_date }}
</p>
- <table class="table table-hover table-condensed">
- <tr>
- <td>{% trans "Energy" %}</td>
- <td>
- {{nutritional_info.total.energy|floatformat}} {% trans "kcal" %}
- </td>
- </tr>
- <tr>
- <td>{% trans "Protein" %}</td>
- <td>
- {{nutritional_info.total.protein|floatformat}} {% trans_weight_unit 'g' user %}
- </td>
- </tr>
- <tr>
- <td>{% trans "Carbohydrates" %}</td>
- <td>
- {{nutritional_info.total.carbohydrates|floatformat}} {% trans_weight_unit 'g' user %}
- </td>
- </tr>
- <tr>
- <td>{% trans "Fat" %}</td>
- <td>
- {{nutritional_info.total.fat|floatformat}} {% trans_weight_unit 'g' user %}
- </td>
- </tr>
- </table>
{% endif %}
+ <table class="table table-hover table-condensed">
+ <tr>
+ <td>{% trans "Energy" %}</td>
+ <td>
+ {{nutritional_info.total.energy|floatformat|default:"-/-"}} {% trans "kcal" %}
+ </td>
+ </tr>
+ <tr>
+ <td>{% trans "Protein" %}</td>
+ <td>
+ {{nutritional_info.total.protein|floatformat|default:"-/-"}} {% trans_weight_unit 'g' user %}
+ </td>
+ </tr>
+ <tr>
+ <td>{% trans "Carbohydrates" %}</td>
+ <td>
+ {{nutritional_info.total.carbohydrates|floatformat|default:"-/-"}} {% trans_weight_unit 'g' user %}
+ </td>
+ </tr>
+ <tr>
+ <td>{% trans "Fat" %}</td>
+ <td>
+ {{nutritional_info.total.fat|floatformat|default:"-/-"}} {% trans_weight_unit 'g' user %}
+ </td>
+ </tr>
+ </table>
</div>
<div class="col-sm-4">
<h4>{% trans "Weight"%}</h4>
diff --git a/wger/core/views/misc.py b/wger/core/views/misc.py
index 0fd694252..8e7151d9a 100644
--- a/wger/core/views/misc.py
+++ b/wger/core/views/misc.py
@@ -107,25 +107,25 @@ def dashboard(request):
template_data['weight'] = weight
template_data['last_weight_entries'] = get_last_entries(request.user)
+ # Format a bit the days so it doesn't have to be done in the template
+ used_days = {}
if current_workout:
- # Format a bit the days so it doesn't have to be done in the template
- used_days = {}
for day in current_workout.day_set.select_related():
for day_of_week in day.day.select_related():
used_days[day_of_week.id] = day.description
- week_day_result = []
- for week in DaysOfWeek.objects.all():
- day_has_workout = False
+ week_day_result = []
+ for week in DaysOfWeek.objects.all():
+ day_has_workout = False
- if week.id in used_days:
- day_has_workout = True
- week_day_result.append((_(week.day_of_week), used_days[week.id], True))
+ if week.id in used_days:
+ day_has_workout = True
+ week_day_result.append((_(week.day_of_week), used_days[week.id], True))
- if not day_has_workout:
- week_day_result.append((_(week.day_of_week), _('Rest day'), False))
+ if not day_has_workout:
+ week_day_result.append((_(week.day_of_week), _('Rest day'), False))
- template_data['weekdays'] = week_day_result
+ template_data['weekdays'] = week_day_result
if plan: