Self hosted FLOSS fitness/workout, nutrition and weight tracker
Don't show edit links if there are no categories on overview
Roland Geider1cc1ea213eca
diff --git a/wger/exercises/templates/overview.html b/wger/exercises/templates/overview.htmlindex 5f94094f3..b562c0665 100644--- a/wger/exercises/templates/overview.html+++ b/wger/exercises/templates/overview.html@@ -134,6 +134,7 @@ $(document).ready(function() {{% if perms.exercises %}<h3>{% trans "Options" %}</h3>+ {% if categories %}<p>{% with category=categories|first %}<a href="{% url 'exercisecategory-edit' category.id %}"@@ -147,8 +148,8 @@ $(document).ready(function() {{% trans "Edit category" %}:<span class="current-category-name">{{category.name}}</span></a>- {% endwith %}</p>+ {% endwith %}<p>{% with category=categories|first %}<a href="{% url 'exercisecategory-delete' category.id %}"@@ -164,6 +165,8 @@ $(document).ready(function() {</a>{% endwith %}</p>+ {% endif %}+<p><a href="{% url 'exercisecategory-add' %}"class="modal-dialog">diff --git a/wger/exercises/tests/exercise.py b/wger/exercises/tests/exercise.pyindex 1bbd5b41c..0a8517540 100644--- a/wger/exercises/tests/exercise.py+++ b/wger/exercises/tests/exercise.py@@ -18,6 +18,7 @@ from django.core import mailfrom django.core.urlresolvers import reversefrom wger.exercises.models import Exercise+from wger.exercises.models import ExerciseCategoryfrom wger.exercises.models import EXERCISE_STATUS_PENDINGfrom wger.exercises.models import EXERCISE_STATUS_ACCEPTEDfrom wger.exercises.models import EXERCISE_STATUS_DECLINED@@ -109,6 +110,16 @@ class ExerciseIndexTestCase(WorkoutManagerTestCase):self.exercise_index(logged_in=False)+ def test_empty_exercise_index(self):+ '''+ Test the index when there are no categories+ '''+ self.user_login('admin')+ ExerciseCategory.objects.all().delete()+ response = self.client.get(reverse('wger.exercises.views.exercises.overview'))+ self.assertEqual(response.status_code, 200)+ self.assertContains(response, 'No categories')+class ExerciseDetailTestCase(WorkoutManagerTestCase):'''