Self hosted FLOSS fitness/workout, nutrition and weight tracker
Don't force users to add individual ingredients/products to a plan
Roland Geiderbf84232ea11d
diff --git a/wger/core/templates/user/overview.html b/wger/core/templates/user/overview.htmlindex 95d931c1b..b21b7099c 100644--- a/wger/core/templates/user/overview.html+++ b/wger/core/templates/user/overview.html@@ -144,7 +144,6 @@<h4>{% translate "Nutrition plans" %} <small>({% blocktranslate with number=5 %}last {{ number }}{% endblocktranslate %})</small></h4>{% if perms.gym.gym_trainer %}<a href="{{trainer_login}}?next={% url 'nutrition:plan:overview' %}" class="btn btn-light btn-sm">{% translate "Overview" %}</a>- <a href="{{trainer_login}}?next={% url 'nutrition:plan:add' %}" class="btn btn-light btn-sm">{% translate "Add nutrition plan" %}</a>{% endif %}<table class="table">diff --git a/wger/core/tests/api_base_test.py b/wger/core/tests/api_base_test.pyindex b69de9364..c8ca8793c 100644--- a/wger/core/tests/api_base_test.py+++ b/wger/core/tests/api_base_test.py@@ -177,14 +177,9 @@ class ApiGetTestCase:if self.overview_cached:cache_length = len(locmem._caches['wger-cache'])self.assertNotEqual(cache_length, 0)-- # TODO: Commented out because the nutritional plan caused this to fail.- # Since we do everything over the API now, we should decide one of- # these days if we want to move the calculations for the nutritional- # values out of the client and just read this- # else:- # cache_length = len(locmem._caches['wger-cache'])- # self.assertEqual(cache_length, 0)+ else:+ cache_length = len(locmem._caches['wger-cache'])+ self.assertEqual(cache_length, 0)def test_special_endpoints(self):"""diff --git a/wger/core/tests/test_index.py b/wger/core/tests/test_index.pyindex f26304fed..3c7f72f25 100644--- a/wger/core/tests/test_index.py+++ b/wger/core/tests/test_index.py@@ -62,19 +62,7 @@ class DashboardTestCase(WgerTestCase):self.assertTrue(response.context['weekdays'])#- # 2. Add a nutrition plan- #- self.client.get(reverse('nutrition:plan:add'))- response = self.client.get(reverse('core:dashboard'))-- self.assertEqual(response.status_code, 200)- self.assertFalse(response.context['weight'])- self.assertTrue(response.context['current_workout'])- self.assertTrue(response.context['plan'])- self.assertTrue(response.context['weekdays'])-- #- # 3. Add a weight entry+ # 2. Add a weight entry#self.client.post(reverse('weight:add'), {'weight': 100,@@ -86,7 +74,6 @@ class DashboardTestCase(WgerTestCase):self.assertEqual(response.status_code, 200)self.assertTrue(response.context['weight'])self.assertTrue(response.context['current_workout'])- self.assertTrue(response.context['plan'])self.assertTrue(response.context['weekdays'])def test_dashboard_logged_in(self):diff --git a/wger/nutrition/api/serializers.py b/wger/nutrition/api/serializers.pyindex 51f510ca1..35fb67710 100644--- a/wger/nutrition/api/serializers.py+++ b/wger/nutrition/api/serializers.py@@ -174,6 +174,7 @@ class IngredientInfoSerializer(serializers.ModelSerializer):depth = 1fields = ['id',+ 'uuid','code','name','created',@@ -323,6 +324,7 @@ class NutritionPlanSerializer(serializers.ModelSerializer):'id','creation_date','description',+ 'only_logging','get_nutritional_values',]diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.pyindex 72411fbdd..3d2cbd651 100644--- a/wger/nutrition/api/views.py+++ b/wger/nutrition/api/views.py@@ -16,12 +16,10 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# Standard Library-import datetimeimport logging# Djangofrom django.conf import settings-from django.shortcuts import get_object_or_404from django.utils.decorators import method_decoratorfrom django.views.decorators.cache import cache_page@@ -77,7 +75,6 @@ from wger.utils.constants import ENGLISH_SHORT_NAMEfrom wger.utils.language import load_languagefrom wger.utils.viewsets import WgerOwnerObjectModelViewSet-logger = logging.getLogger(__name__)diff --git a/wger/nutrition/migrations/0017_remove_nutritionplan_language_alter_logitem_meal.py b/wger/nutrition/migrations/0017_remove_nutritionplan_language_alter_logitem_meal.pyindex fbcdd8f5d..4d2e51820 100644--- a/wger/nutrition/migrations/0017_remove_nutritionplan_language_alter_logitem_meal.py+++ b/wger/nutrition/migrations/0017_remove_nutritionplan_language_alter_logitem_meal.py@@ -26,4 +26,9 @@ class Migration(migrations.Migration):verbose_name='Meal'),),+ migrations.AddField(+ model_name='nutritionplan',+ name='only_logging',+ field=models.BooleanField(default=False, verbose_name='Only logging'),+ ),]diff --git a/wger/nutrition/models/plan.py b/wger/nutrition/models/plan.pyindex 7e54a967a..dc8ce9e22 100644--- a/wger/nutrition/models/plan.py+++ b/wger/nutrition/models/plan.py@@ -70,6 +70,13 @@ class NutritionPlan(models.Model):'"Gain mass" or "Prepare for summer"'),)++ only_logging = models.BooleanField(+ verbose_name='Only logging',+ default=False,+ )+ """Flag to indicate that the nutritional plan will only used for logging"""+has_goal_calories = models.BooleanField(verbose_name=_('Use daily calories'),default=False,diff --git a/wger/nutrition/tests/test_plan.py b/wger/nutrition/tests/test_plan.pyindex fa5b9a914..a71664c45 100644--- a/wger/nutrition/tests/test_plan.py+++ b/wger/nutrition/tests/test_plan.py@@ -21,10 +21,13 @@ from wger.nutrition.models import NutritionPlanclass PlanApiTestCase(api_base_test.ApiBaseResourceTestCase):"""Tests the nutritional plan overview resource++ TODO: setting overview_cached to true since get_nutritional_values is+ cached, but we don't really use it. This should be removed"""pk = 4resource = NutritionPlanprivate_resource = True- overview_cached = False+ overview_cached = Truespecial_endpoints = ('nutritional_values', )data = {'description': 'The description'}