Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add some more options to the index view.

Roland Geider9b5206fa1f23
diff --git a/manager/templates/index.html b/manager/templates/index.html
index b6df9ed75..d9de1f3e3 100644
--- a/manager/templates/index.html
+++ b/manager/templates/index.html
@@ -1,20 +1,104 @@
{% extends "base.html" %}
{% load i18n %}
+{% load staticfiles %}
{% block title %} {% trans "Workout list" %}{% endblock %}
+
{% block content %}
-{% if latest_workouts_list %}
- <ul>
- {% for workout in latest_workouts_list %}
- <li><a href="{% url manager.views.view_workout workout.id %}">{{ workout.creation_date }}</a></li>
- {% endfor %}
- </ul>
-{% else %}
- <div class="box warning">
- {% trans "No workouts found." %} {% trans "Use link to add one." %}
+<h1>{% trans "Welcome"%} {{ user.username }}</h1>
+
+
+<div class="ym-grid linearize-level-1">
+ <div class="ym-g50 ym-gl">
+ <div class="ym-gbox-left">
+ <h2>{% trans "Your workouts"%}</h2>
+ {% if latest_workouts_list %}
+ <ul>
+ {% for workout in latest_workouts_list %}
+ <li><a href="{% url manager.views.view_workout workout.id %}">
+ {% if workout.comment %}
+ {{ workout.comment }}
+ {% else %}
+ {% trans "Workout" %}
+ {% endif %}
+ </a>
+ <br> – {{ workout.creation_date }}
+ </li>
+ {% endfor %}
+ </ul>
+ {% else %}
+ <div class="box warning">
+ {% trans "No workouts found." %} {% trans "Use link to add one." %}
+ </div>
+ {% endif %}
+ </div>
</div>
+ <div class="ym-g50 ym-gr">
+ <div class="ym-gbox-right">
+
+
+ <h2>{% trans "Your diet plans"%}</h2>
+
+ {% if plans %}
+ <ul>
+ {% for plan in plans %}
+ <li><a href="{% url nutrition.views.view plan.id %}">
+ {% if plan.description %}
+ {{ plan.description }}
+ {% else %}
+ {% trans "Nutrition plan" %}
+ {% endif %}
+ </a>
+ <br> – {{ plan.creation_date }}
+ </li>
+ {% endfor %}
+ </ul>
+ {% else %}
+ <div class="box warning">
+ {% trans "No nutrition plans." %} {% trans "Use link to add one." %}
+ </div>
+ {% endif %}
+
+ <p>
+ {% trans "Your current weight is: "%} <strong>{{weight.weight}} kg.</strong>
+ </p>
+
+ </div>
+ </div>
+</div>
+
+<div class="ym-grid linearize-level-1">
+ <div class="ym-g50 ym-gl">
+ <div class="ym-gbox-left">
+ <p>
+ <a href="{% url manager.views.add %}">
+ <img src="{% static 'images/icons/new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add new exercise' %}"
+ title="{% trans 'Add new exercise' %}">
+ {% trans "Add workout" %}</a>
+ </p>
+ </div>
+ </div>
+ <div class="ym-g50 ym-gr">
+ <div class="ym-gbox-right">
+ <p>
+ <a href="{% url nutrition.views.add %}">
+ <img src="{% static 'images/icons/new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add new exercise' %}"
+ title="{% trans 'Add new exercise' %}">
+ {% trans "Add nutrition plan" %}</a>
+ </p>
+ </div>
+ </div>
+</div>
+
-{% endif %}
-<p><a href="{% url manager.views.add %}">{% trans "Add workout" %}</a></p>
{% endblock %}
+
+
+
diff --git a/manager/views.py b/manager/views.py
index ab1828c64..c740db19c 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -38,6 +38,10 @@ from manager.models import Setting
from exercises.models import Exercise
+from nutrition.models import NutritionPlan
+
+from weight.models import WeightEntry
+
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import A4, cm
from reportlab.platypus import Paragraph, SimpleDocTemplate, Table
@@ -59,6 +63,13 @@ def index(request):
latest_trainings = TrainingSchedule.objects.filter(user=request.user).order_by('-creation_date')[:5]
template_data['latest_workouts_list'] = latest_trainings
+ plans = NutritionPlan.objects.filter(user = request.user)
+ template_data['plans'] = plans
+
+ weight = WeightEntry.objects.filter(user = request.user).latest('creation_date')
+ template_data['weight'] = weight
+
+
return render_to_response('index.html',
template_data,
context_instance=RequestContext(request))