Self hosted FLOSS fitness/workout, nutrition and weight tracker
Serve the nutrition diary pages when opened directly
Alex Castilloc2d76d9f5df4
diff --git a/wger/nutrition/tests/test_plan.py b/wger/nutrition/tests/test_plan.pyindex 8c69dacb6..962da3717 100644--- a/wger/nutrition/tests/test_plan.py+++ b/wger/nutrition/tests/test_plan.py@@ -82,3 +82,22 @@ class PlanCopyTestCase(WgerTestCase):copied_dict = model_to_dict(copied_meal_item, exclude=['id', 'meal'])self.assertEqual(orig_dict, copied_dict)self.assertNotEqual(orig_meal_item.id, copied_meal_item.id)+++class PlanDiaryPageTestCase(WgerTestCase):+ """+ The React frontend links each diary date of a plan as /<lang>/nutrition/<plan>/<date>,+ so the page must also load when opened directly (new tab, reload, bookmark).+ """++ def test_diary_date_page_loads_directly(self):+ self.user_login()+ response = self.client.get(+ f'/en/nutrition/{PLAN_OWNED_BY_TEST_USER}/2026-10-11', follow=True+ )+ self.assertEqual(response.status_code, 200)++ def test_diary_page_loads_directly(self):+ self.user_login()+ response = self.client.get(f'/en/nutrition/{PLAN_OWNED_BY_TEST_USER}/diary', follow=True)+ self.assertEqual(response.status_code, 200)diff --git a/wger/nutrition/urls.py b/wger/nutrition/urls.pyindex 016dfc29e..9a15a378d 100644--- a/wger/nutrition/urls.py+++ b/wger/nutrition/urls.py@@ -18,7 +18,10 @@# Djangofrom django.conf.urls import includefrom django.contrib.auth.decorators import login_required-from django.urls import path+from django.urls import (+ path,+ re_path,+)# wgerfrom wger.core.views.react import ReactView@@ -42,6 +45,18 @@ patterns_plan = [ReactView.as_view(login_required=True),name='view',),+ # The nutrition diary pages are React routes too (/<plan>/diary and /<plan>/<date>),+ # so they need to load when opened directly, e.g. from a new tab or a bookmark+ path(+ '<uuid:id>/diary/',+ ReactView.as_view(login_required=True),+ name='diary',+ ),+ re_path(+ r'^(?P<id>[0-9a-f-]+)/(?P<date>\d{4}-\d{2}-\d{2})/$',+ ReactView.as_view(login_required=True),+ name='diary-date',+ ),path('<uuid:pk>/copy',plan.copy,