Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Hightlight the active tab

Roland Geiderbaca622ea89c
diff --git a/exercises/views.py b/exercises/views.py
index b9386e97c..88c61d797 100644
--- a/exercises/views.py
+++ b/exercises/views.py
@@ -83,6 +83,7 @@ def exercise_overview(request):
template_data = {}
template_data['categories'] = ExerciseCategory.objects.filter(language = language.id)
+ template_data['active_tab'] = 'exercises'
return render_to_response('overview.html',
template_data,
@@ -98,6 +99,7 @@ def exercise_view(request, id, comment_id=None):
# Load the exercise itself
exercise = get_object_or_404(Exercise, pk=id)
template_data['exercise'] = exercise
+ template_data['active_tab'] = 'exercises'
#
# We can create and edit comments from this page, so look for Posts
@@ -146,6 +148,7 @@ def exercise_view(request, id, comment_id=None):
def exercise_edit(request, id=None):
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'exercises'
if not id:
exercise = Exercise()
@@ -182,6 +185,7 @@ def exercise_delete(request, id):
def exercise_category_edit(request, id):
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'exercises'
if not id:
category = ExerciseCategory()
diff --git a/manager/templates/base.html b/manager/templates/base.html
index e9f871a4b..1566bfbd4 100644
--- a/manager/templates/base.html
+++ b/manager/templates/base.html
@@ -46,9 +46,10 @@
<div class="ym-wrapper">
<div class="ym-hlist">
<ul>
- <li><a href="/">{% trans "Workouts" %}</a></li>
- <li><a href="/weight/overview/">{% trans "Weight" %} </a></li>
- <li><a href="/exercise/overview/">{% trans "Exercises" %}</a></li>
+
+ <li {% if active_tab == 'workout' %}class="active"{% endif %}><a href="/">{% trans "Workouts" %}</a></li>
+ <li {% if active_tab == 'weight' %}class="active"{% endif %}><a href="/weight/overview/">{% trans "Weight" %} </a></li>
+ <li {% if active_tab == 'exercises' %}class="active"{% endif %}><a href="/exercise/overview/">{% trans "Exercises" %}</a></li>
</ul>
diff --git a/manager/views.py b/manager/views.py
index 35b80ea7a..89bf718d6 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -55,9 +55,15 @@ logger = logging.getLogger('workout_manager.custom')
def index(request):
"""Show the index page, in our case, a list of workouts
"""
+
+ template_data = {}
+ template_data['active_tab'] = 'workout'
+
latest_trainings = TrainingSchedule.objects.filter(user=request.user).order_by('-creation_date')[:5]
+ template_data['latest_workouts_list'] = latest_trainings
+
return render_to_response('index.html',
- {'latest_workouts_list': latest_trainings},
+ template_data,
context_instance=RequestContext(request))
@@ -66,6 +72,7 @@ def login(request):
"""
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'workout'
template_data['form'] = AuthenticationForm()
@@ -113,6 +120,7 @@ def view_workout(request, id):
"""Show the workout with the given ID
"""
template_data = {}
+ template_data['active_tab'] = 'workout'
workout = get_object_or_404(TrainingSchedule, pk=id, user=request.user)
template_data['workout'] = workout
@@ -293,6 +301,7 @@ def edit_day(request, id, day_id=None):
"""
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'workout'
# Load workout
workout = get_object_or_404(TrainingSchedule, pk=id, user=request.user)
@@ -353,7 +362,6 @@ def view_day(request, id):
"""
template_data = {}
-
# Load day and check if its workout belongs to the user
day = get_object_or_404(Day, pk=id)
if day.training.user != request.user:
@@ -383,6 +391,7 @@ def edit_set(request, id, day_id, set_id=None):
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'workout'
# Load workout
workout = get_object_or_404(TrainingSchedule, pk=id, user=request.user)
@@ -483,6 +492,7 @@ class SettingForm(ModelForm):
def edit_setting(request, id, set_id, exercise_id, setting_id=None):
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'workout'
# Load workout
workout = get_object_or_404(TrainingSchedule, pk=id, user=request.user)
diff --git a/weight/views.py b/weight/views.py
index 3142f87fa..568c3dfa9 100644
--- a/weight/views.py
+++ b/weight/views.py
@@ -42,6 +42,7 @@ def add(request, id=None):
template_data = {}
template_data.update(csrf(request))
+ template_data['active_tab'] = 'weight'
# Load weight
if id:
@@ -101,6 +102,7 @@ def overview(request):
template_data = {}
weights = WeightEntry.objects.filter(user = request.user)
template_data['weights'] = weights
+ template_data['active_tab'] = 'weight'
# Process the data to pass it to the JS libraries to generate an SVG image
data_y = ', '.join([str(i.weight) for i in weights])