Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correctly filter out pending exercises from overview

Roland Geider1a7bfd531838
diff --git a/wger/exercises/templates/overview.html b/wger/exercises/templates/overview.html
index 25bf74812..de7aacc38 100644
--- a/wger/exercises/templates/overview.html
+++ b/wger/exercises/templates/overview.html
@@ -2,6 +2,7 @@
{% load url from future %}
{% load i18n %}
{% load staticfiles %}
+{% load manager_extras %}
<!--
Title
@@ -68,7 +69,7 @@ $(document).ready(function() {
<div id="cat{{ category.id }}">
<table class="narrow">
<tbody>
- {% for exercise in category.exercise_set.all %}
+ {% for exercise in category|get_active_exercises %}
<tr>
<td>
<a href="{{ exercise.get_absolute_url }}">{{ exercise.name }}</a>
diff --git a/wger/manager/templatetags/manager_extras.py b/wger/manager/templatetags/manager_extras.py
index fec1f37fb..f62247854 100644
--- a/wger/manager/templatetags/manager_extras.py
+++ b/wger/manager/templatetags/manager_extras.py
@@ -17,6 +17,7 @@
from django import template
from django.core.paginator import EmptyPage, PageNotAnInteger
+from wger.exercises.models import Exercise
from wger.utils.constants import PAGINATION_OBJECTS_PER_PAGE
from wger.utils.constants import PAGINATION_MAX_TOTAL_PAGES
from wger.utils.constants import PAGINATION_PAGES_AROUND_CURRENT
@@ -29,12 +30,21 @@ def get_current_settings(exercise, set_id):
'''
Does a filter on the sets
- We need to do this here because it's not possible to pass arguments to function in the template,
- and we are only interested on the settings that belong to the current set
+ We need to do this here because it's not possible to pass arguments to function in
+ the template, and we are only interested on the settings that belong to the current
+ set
'''
return exercise.setting_set.filter(set_id=set_id)
[email protected](name='get_active_exercises')
+def get_active_exercises(category):
+ '''
+ Filter out pending exercises
+ '''
+ return category.exercise_set.filter(status__in=Exercise.EXERCISE_STATUS_OK)
+
+
@register.inclusion_tag('tags/render_day.html')
def render_day(day):
'''