diff --git a/apps/activity/templates/activity/includes/activity_info.html b/apps/activity/templates/activity/includes/activity_info.html
index 5a8887e2..ee403ba0 100644
--- a/apps/activity/templates/activity/includes/activity_info.html
+++ b/apps/activity/templates/activity/includes/activity_info.html
@@ -65,11 +65,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% if activity.open and activity.activity_type.manage_entries and ".change__open"|has_perm:activity %}
{% trans "Entry page" %}
{% endif %}
- {% if false %}
{% if activity.activity_type.name == "Perm bouffe" %}
{% trans "Dish page" %}
{% endif %}
- {% endif %}
{% if request.path_info == activity_detail_url %}
{% if activity.valid and ".change__open"|has_perm:activity %}
diff --git a/apps/food/forms.py b/apps/food/forms.py
index 2b09699a..925bb18c 100644
--- a/apps/food/forms.py
+++ b/apps/food/forms.py
@@ -13,6 +13,7 @@ from member.models import Club
from note_kfet.inputs import Autocomplete, AmountInput
from note_kfet.middlewares import get_current_request
from permission.backends import PermissionBackend
+from activity.models import Activity
from .models import Food, BasicFood, TransformedFood, QRCode, Dish, Supplement, Order, Recipe
@@ -201,6 +202,17 @@ class DishForm(forms.ModelForm):
"""
Form to create a dish
"""
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ # TODO find a better way to get pk (be not url scheme dependant)
+ pk = get_current_request().path.split('/')[3]
+ club = Activity.objects.get(pk=pk).organizer
+ qs = self.fields['main'].queryset.filter(
+ owner=club,
+ end_of_life=''
+ ).filter(PermissionBackend.filter_queryset(get_current_request(), Food, "change"))
+ self.fields['main'].queryset = qs
+
class Meta:
model = Dish
fields = ('main', 'price', 'available')
@@ -213,6 +225,17 @@ class SupplementForm(forms.ModelForm):
"""
Form to create a dish
"""
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ # TODO find a better way to get pk (be not url scheme dependant)
+ pk = get_current_request().path.split('/')[3]
+ club = Activity.objects.get(pk=pk).organizer
+ qs = self.fields['food'].queryset.filter(
+ owner=club,
+ end_of_life=''
+ ).filter(PermissionBackend.filter_queryset(get_current_request(), Food, "change"))
+ self.fields['food'].queryset = qs
+
class Meta:
model = Supplement
fields = '__all__'
diff --git a/apps/food/templates/food/dish_list.html b/apps/food/templates/food/dish_list.html
index 62acfb9b..97e039db 100644
--- a/apps/food/templates/food/dish_list.html
+++ b/apps/food/templates/food/dish_list.html
@@ -17,6 +17,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% trans "New dish" %}
{% endif %}
{% trans "Activity page" %}
+ {% trans "Order food" %}
+ {% trans "Order list" %}
{% trans "Return to the food list" %}
diff --git a/apps/food/templates/food/food_detail.html b/apps/food/templates/food/food_detail.html
index c0bc9555..024dee1e 100644
--- a/apps/food/templates/food/food_detail.html
+++ b/apps/food/templates/food/food_detail.html
@@ -47,11 +47,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% trans "Manage ingredients" %}
- {% if false %}
{% trans "Use a recipe" %}
- {% endif %}
{% endif %}
{% trans "Return to the food list" %}
diff --git a/apps/food/templates/food/food_list.html b/apps/food/templates/food/food_list.html
index d126f607..54c8fb1c 100644
--- a/apps/food/templates/food/food_list.html
+++ b/apps/food/templates/food/food_list.html
@@ -70,7 +70,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% trans "New meal" %}
{% endif %}
- {% if false %}
{% if can_view_recipes %}
{% trans "View recipes" %}
@@ -86,7 +85,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% trans "View" %} {{ activity.name }}
{% endfor %}
- {% endif %}
{% if served.data %}
diff --git a/apps/food/tests/test_food.py b/apps/food/tests/test_food.py
index 38629a43..4c4d356d 100644
--- a/apps/food/tests/test_food.py
+++ b/apps/food/tests/test_food.py
@@ -11,7 +11,7 @@ from member.models import Club
from ..api.views import AllergenViewSet, BasicFoodViewSet, TransformedFoodViewSet, QRCodeViewSet, \
DishViewSet, SupplementViewSet, OrderViewSet, FoodTransactionViewSet
-from ..models import Allergen, BasicFood, TransformedFood, QRCode, Dish, Supplement, Order # TODO FoodTransaction
+from ..models import Allergen, BasicFood, TransformedFood, QRCode, Dish, Supplement, Order, FoodTransaction
class TestFood(TestCase):
@@ -120,7 +120,7 @@ class TestFood(TestCase):
self.assertEqual(response.status_code, 200)
-'''class TestFoodOrder(TestCase):
+class TestFoodOrder(TestCase):
"""
Test Food Order
"""
@@ -337,7 +337,7 @@ class TestFood(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTrue(Order.objects.filter(dish=self.dish, user=self.user, served=False).exists())
- self.assertTrue(FoodTransaction.objects.filter(order=self.order, valid=False).exists())'''
+ self.assertTrue(FoodTransaction.objects.filter(order=self.order, valid=False).exists())
class TestFoodAPI(TestAPI):
diff --git a/apps/food/urls.py b/apps/food/urls.py
index 299548f6..00bdc3e3 100644
--- a/apps/food/urls.py
+++ b/apps/food/urls.py
@@ -20,19 +20,19 @@ urlpatterns = [
path('add/ingredient//', views.AddIngredientView.as_view(), name='add_ingredient'),
path('redirect/', views.QRCodeRedirectView.as_view(), name='redirect_view'),
# TODO not always store activity_pk in url
- # path('activity//dishes/add/', views.DishCreateView.as_view(), name='dish_create'),
- # path('activity//dishes/', views.DishListView.as_view(), name='dish_list'),
- # path('activity//dishes//', views.DishDetailView.as_view(), name='dish_detail'),
- # path('activity//dishes//update/', views.DishUpdateView.as_view(), name='dish_update'),
- # path('activity//dishes//delete/', views.DishDeleteView.as_view(), name='dish_delete'),
- # path('activity//order/', views.OrderCreateView.as_view(), name='order_create'),
- # path('activity//orders/', views.OrderListView.as_view(), name='order_list'),
- # path('activity//orders/served', views.ServedOrderListView.as_view(), name='served_order_list'),
- # path('activity//kitchen/', views.KitchenView.as_view(), name='kitchen'),
- # path('recipe/add/', views.RecipeCreateView.as_view(), name='recipe_create'),
- # path('recipe/', views.RecipeListView.as_view(), name='recipe_list'),
- # path('recipe//', views.RecipeDetailView.as_view(), name='recipe_detail'),
- # path('recipe//update/', views.RecipeUpdateView.as_view(), name='recipe_update'),
- # path('update/ingredients//recipe/', views.UseRecipeView.as_view(), name='recipe_use'),
- # path('ajax/get_ingredients/', views.get_ingredients_for_recipe, name='get_ingredients'),
+ path('activity//dishes/add/', views.DishCreateView.as_view(), name='dish_create'),
+ path('activity//dishes/', views.DishListView.as_view(), name='dish_list'),
+ path('activity//dishes//', views.DishDetailView.as_view(), name='dish_detail'),
+ path('activity//dishes//update/', views.DishUpdateView.as_view(), name='dish_update'),
+ path('activity//dishes//delete/', views.DishDeleteView.as_view(), name='dish_delete'),
+ path('activity//order/', views.OrderCreateView.as_view(), name='order_create'),
+ path('activity//orders/', views.OrderListView.as_view(), name='order_list'),
+ path('activity//orders/served', views.ServedOrderListView.as_view(), name='served_order_list'),
+ path('activity//kitchen/', views.KitchenView.as_view(), name='kitchen'),
+ path('recipe/add/', views.RecipeCreateView.as_view(), name='recipe_create'),
+ path('recipe/', views.RecipeListView.as_view(), name='recipe_list'),
+ path('recipe//', views.RecipeDetailView.as_view(), name='recipe_detail'),
+ path('recipe//update/', views.RecipeUpdateView.as_view(), name='recipe_update'),
+ path('update/ingredients//recipe/', views.UseRecipeView.as_view(), name='recipe_use'),
+ path('ajax/get_ingredients/', views.get_ingredients_for_recipe, name='get_ingredients'),
]