Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

First draft at rewriting the dashboard

Roland Geider35c129e74f93
diff --git a/wger/core/templates/index.html b/wger/core/templates/index.html
index dbcefaef4..a30a528f4 100644
--- a/wger/core/templates/index.html
+++ b/wger/core/templates/index.html
@@ -1,8 +1,11 @@
-{% extends "base.html" %}
+{% extends "base_wide.html" %}
{% load i18n staticfiles wger_extras %}
{% block title %}{% trans "Dashboard" %}{% endblock %}
+{# #}
+{# Header #}
+{# #}
{% block header %}
{% endblock %}
@@ -27,15 +30,13 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
{% endfor %}
{% else %}
- <p><em>{% trans "No workouts found." %}</em></p>
<p>
- <a href="{% url 'manager:workout:add' %}" class="btn btn-block btn-default">
- <img src="{% static 'images/icons/add.svg' %}"
- width="22"
- height="22"
- alt="">
- {% trans "Add one now." %}
- </a>
+ <em>{% trans "No workouts found." %}</em>
+ </p>
+ <p>
+ <a href="{% url 'manager:workout:add' %}" class="btn btn-success btn-sm">
+ {% trans "Add workout" %}
+ </a>
</p>
{% endif %}
</div>
@@ -45,33 +46,37 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
{% endif %}
<div class="row">
- <div class="col-sm-6">
+ <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>
+ <a href="{{ current_workout.get_absolute_url }}">
+ {% if current_workout.comment %}
+ {{ current_workout.comment }}
+ {% else %}
+ {% trans "Workout" %}
+ {% endif %}
+ </a>
</p>
- – {{ current_workout.creation_date }}
+ <p>
+ – {{ current_workout.creation_date }}
+ <p>
- <ul>
+ <table class="table table-hover">
{% for day, exercise, is_workout in weekdays %}
- <li>
- {% if not is_workout %}<span class="text-muted">{% endif%}
- {{ day }}:
-
- {{ exercise }}
- {% if not is_workout %}</span>{% endif%}
-
- </li>
+ <tr>
+ <td>
+ {{ day }}
+ </td>
+ <td>
+ {% if not is_workout %}<span class="text-muted">{% endif%}
+ {{ exercise }}
+ {% if not is_workout %}</span>{% endif%}
+ </td>
+ </tr>
{% endfor %}
- </ul>
+ </table>
{% if current_workout.day_set.all %}
<p><a href="#" id="logging-popup-link" data-toggle="modal" data-target="#calendar-day-select-popup">{% trans "Add new log" %}</a></p>
@@ -86,73 +91,108 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
{% else %} {# no workout #}
<a href="{% url 'manager:workout:add' %}" class="btn btn-block btn-default">
- {% trans "No workouts found." %} {% trans "Add one now." %}
+ {% trans "No workouts found." %} {% trans "Add one now." %}
</a>
{% endif %}
</div>
- <div class="col-sm-6">
+ <div class="col-sm-4">
<h4>{% trans "Nutrition plan"%}</h4>
{% if plan %}
<p>
- <a href="{{ plan.get_absolute_url }}">{{ plan }}</a>
+ <a href="{{ plan.get_absolute_url }}">{{ plan }}</a>
</p>
- – {{ plan.creation_date }}
- <ul>
- <li>
- {% trans "Energy" %}: {{nutritional_info.total.energy|floatformat}} {% trans "kcal" %}
- </li>
- <li>
- {% trans "Protein" %}: {{nutritional_info.total.protein|floatformat}} {% trans_weight_unit 'g' user %}
- </li>
- <li>
- {% trans "Carbohydrates" %}: {{nutritional_info.total.carbohydrates|floatformat}} {% trans_weight_unit 'g' user %}
- </li>
- <li>
- {% trans "Fat" %}: {{nutritional_info.total.fat|floatformat}} {% trans_weight_unit 'g' user %}
- </li>
- </ul>
+ <p>
+ – {{ plan.creation_date }}
+ </p>
+ <table class="table table-hover">
+ <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>
{% else %}
<p>
<a href="{% url 'nutrition:plan:add' %}" class="btn btn-block btn-default">
- {% trans "No nutrition plans." %} {% trans "Add one now." %}
+ {% trans "No nutrition plans." %} {% trans "Add one now." %}
</a>
</p>
{% endif %}
+ </div>
+ <div class="col-sm-4">
+ <h4>{% trans "Weight"%}</h4>
+ <p>
+ <a href="{% url 'weight:overview' user.username %}">{% trans "Overview" %}</a>
+ </p>
+
{% if weight %}
<p>
{% trans "Your current weight is: "%}
- <strong>
- {{weight.weight|floatformat}} {% trans_weight_unit 'kg' user %}
- </strong>
+ {{weight.weight|floatformat}} {% trans_weight_unit 'kg' user %}
</p>
+ <table class="table table-hover">
+ {% for entry_detail in last_weight_entries %}
+ <tr>
+ <td>
+ {{ entry_detail.0.date }}
+ </td>
+ <td>
+ {{ entry_detail.0.weight }}
+ </td>
+ <td>
+ {% if entry_detail.1 > 0 %}
+ +
+ {% endif %}
+ {% if entry_detail.1 %}
+ {{ entry_detail.1 }}
+ {% else %}
+ -/-
+ {% endif %}
+ <td>
+ </tr>
+ {% endfor %}
+ </table>
{% endif %}
</div>
</div>
+
<div class="row">
- <div class="col-sm-6">
+ <div class="col-sm-4">
+ <p>
+ <a href="{% url 'manager:workout:add' %}" class="btn btn-success btn-sm">{% trans "Add workout" %}</a>
+ </p>
+ </div>
+ <div class="col-sm-4">
<p>
- <a href="{% url 'manager:workout:add' %}">
- <img src="{% static 'images/icons/new.svg' %}"
- width="32"
- height="32"
- alt="{% trans 'Add workout' %}"
- title="{% trans 'Add workout' %}">
- {% trans "Add workout" %}</a>
+ <a href="{% url 'nutrition:plan:add' %}" class="btn btn-success btn-sm">{% trans "Add nutrition plan" %}</a>
</p>
</div>
- <div class="col-sm-6">
+ <div class="col-sm-4">
<p>
- <a href="{% url 'nutrition:plan:add' %}">
- <img src="{% static 'images/icons/new.svg' %}"
- width="32"
- height="32"
- alt="{% trans 'Add nutrition plan' %}"
- title="{% trans 'Add nutrition plan' %}">
- {% trans "Add nutrition plan" %}</a>
+ <a href="{% url 'weight:add' %}" class="btn btn-success btn-sm">{% trans "Add weight entry" %}</a>
</p>
</div>
</div>
@@ -165,6 +205,5 @@ day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</str
<p>{% blocktrans %}The current workout is selected from your active schedule
or, if you don't have one, simply by date.{% endblocktrans %}</p>
-<p>{% trans "After adding a workout or a nutritional plan, you can edit them to set a goal." %}
-</p>
+<p>{% trans "After adding a workout or a nutritional plan, you can edit them to set a goal." %}</p>
{% endblock %}
diff --git a/wger/core/views/misc.py b/wger/core/views/misc.py
index 8d413f362..95257c696 100644
--- a/wger/core/views/misc.py
+++ b/wger/core/views/misc.py
@@ -36,6 +36,7 @@ from wger.core.models import DaysOfWeek
from wger.manager.models import Schedule
from wger.nutrition.models import NutritionPlan
from wger.weight.models import WeightEntry
+from wger.weight.helpers import get_last_entries
logger = logging.getLogger(__name__)
@@ -104,6 +105,7 @@ def dashboard(request):
except ObjectDoesNotExist:
weight = False
template_data['weight'] = weight
+ template_data['last_weight_entries'] = get_last_entries(request.user)
if current_workout:
# Format a bit the days so it doesn't have to be done in the template