mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-12-14 07:15:16 +01:00
First test irl
This commit is contained in:
@@ -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 %}
|
{% if activity.open and activity.activity_type.manage_entries and ".change__open"|has_perm:activity %}
|
||||||
<a class="btn btn-warning btn-sm my-1" href="{% url 'activity:activity_entry' pk=activity.pk %}"> {% trans "Entry page" %}</a>
|
<a class="btn btn-warning btn-sm my-1" href="{% url 'activity:activity_entry' pk=activity.pk %}"> {% trans "Entry page" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if false %}
|
|
||||||
{% if activity.activity_type.name == "Perm bouffe" %}
|
{% if activity.activity_type.name == "Perm bouffe" %}
|
||||||
<a class="btn btn-warning btn-sm my-1" href="{% url 'food:dish_list' activity_pk=activity.pk %}"> {% trans "Dish page" %}</a>
|
<a class="btn btn-warning btn-sm my-1" href="{% url 'food:dish_list' activity_pk=activity.pk %}"> {% trans "Dish page" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if request.path_info == activity_detail_url %}
|
{% if request.path_info == activity_detail_url %}
|
||||||
{% if activity.valid and ".change__open"|has_perm:activity %}
|
{% if activity.valid and ".change__open"|has_perm:activity %}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from member.models import Club
|
|||||||
from note_kfet.inputs import Autocomplete, AmountInput
|
from note_kfet.inputs import Autocomplete, AmountInput
|
||||||
from note_kfet.middlewares import get_current_request
|
from note_kfet.middlewares import get_current_request
|
||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
|
from activity.models import Activity
|
||||||
|
|
||||||
from .models import Food, BasicFood, TransformedFood, QRCode, Dish, Supplement, Order, Recipe
|
from .models import Food, BasicFood, TransformedFood, QRCode, Dish, Supplement, Order, Recipe
|
||||||
|
|
||||||
@@ -201,6 +202,17 @@ class DishForm(forms.ModelForm):
|
|||||||
"""
|
"""
|
||||||
Form to create a dish
|
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:
|
class Meta:
|
||||||
model = Dish
|
model = Dish
|
||||||
fields = ('main', 'price', 'available')
|
fields = ('main', 'price', 'available')
|
||||||
@@ -213,6 +225,17 @@ class SupplementForm(forms.ModelForm):
|
|||||||
"""
|
"""
|
||||||
Form to create a dish
|
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:
|
class Meta:
|
||||||
model = Supplement
|
model = Supplement
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<a class="btn btn-sm btn-success" href="{% url 'food:dish_create' activity_pk=activity.pk %}">{% trans "New dish" %}</a>
|
<a class="btn btn-sm btn-success" href="{% url 'food:dish_create' activity_pk=activity.pk %}">{% trans "New dish" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="btn btn-sm btn-secondary" href="{% url 'activity:activity_detail' pk=activity.pk %}">{% trans "Activity page" %}</a>
|
<a class="btn btn-sm btn-secondary" href="{% url 'activity:activity_detail' pk=activity.pk %}">{% trans "Activity page" %}</a>
|
||||||
|
<a class="btn btn-sm btn-success" href="{% url 'food:order_create' activity_pk=activity.pk %}">{% trans "Order food" %}</a>
|
||||||
|
<a class="btn btn-sm btn-secondary" href="{% url 'food:order_list' activity_pk=activity.pk %}">{% trans "Order list" %}</a>
|
||||||
<a class="btn btn-sm btn-primary" href="{% url "food:food_list" %}">
|
<a class="btn btn-sm btn-primary" href="{% url "food:food_list" %}">
|
||||||
{% trans "Return to the food list" %}
|
{% trans "Return to the food list" %}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -47,12 +47,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<a class="btn btn-sm btn-secondary" href="{% url "food:manage_ingredients" pk=food.pk %}">
|
<a class="btn btn-sm btn-secondary" href="{% url "food:manage_ingredients" pk=food.pk %}">
|
||||||
{% trans "Manage ingredients" %}
|
{% trans "Manage ingredients" %}
|
||||||
</a>
|
</a>
|
||||||
{% if false %}
|
|
||||||
<a class="btn btn-sm btn-secondary" href="{% url "food:recipe_use" pk=food.pk %}">
|
<a class="btn btn-sm btn-secondary" href="{% url "food:recipe_use" pk=food.pk %}">
|
||||||
{% trans "Use a recipe" %}
|
{% trans "Use a recipe" %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
<a class="btn btn-sm btn-primary" href="{% url "food:food_list" %}">
|
<a class="btn btn-sm btn-primary" href="{% url "food:food_list" %}">
|
||||||
{% trans "Return to the food list" %}
|
{% trans "Return to the food list" %}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% trans "New meal" %}
|
{% trans "New meal" %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if false %}
|
|
||||||
{% if can_view_recipes %}
|
{% if can_view_recipes %}
|
||||||
<a class="btn btn-sm btn-secondary" href="{% url 'food:recipe_list' %}">
|
<a class="btn btn-sm btn-secondary" href="{% url 'food:recipe_list' %}">
|
||||||
{% trans "View recipes" %}
|
{% trans "View recipes" %}
|
||||||
@@ -86,7 +85,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% trans "View" %} {{ activity.name }}
|
{% trans "View" %} {{ activity.name }}
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if served.data %}
|
{% if served.data %}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from member.models import Club
|
|||||||
|
|
||||||
from ..api.views import AllergenViewSet, BasicFoodViewSet, TransformedFoodViewSet, QRCodeViewSet, \
|
from ..api.views import AllergenViewSet, BasicFoodViewSet, TransformedFoodViewSet, QRCodeViewSet, \
|
||||||
DishViewSet, SupplementViewSet, OrderViewSet, FoodTransactionViewSet
|
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):
|
class TestFood(TestCase):
|
||||||
@@ -120,7 +120,7 @@ class TestFood(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
'''class TestFoodOrder(TestCase):
|
class TestFoodOrder(TestCase):
|
||||||
"""
|
"""
|
||||||
Test Food Order
|
Test Food Order
|
||||||
"""
|
"""
|
||||||
@@ -337,7 +337,7 @@ class TestFood(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTrue(Order.objects.filter(dish=self.dish, user=self.user, served=False).exists())
|
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):
|
class TestFoodAPI(TestAPI):
|
||||||
|
|||||||
@@ -20,19 +20,19 @@ urlpatterns = [
|
|||||||
path('add/ingredient/<int:pk>/', views.AddIngredientView.as_view(), name='add_ingredient'),
|
path('add/ingredient/<int:pk>/', views.AddIngredientView.as_view(), name='add_ingredient'),
|
||||||
path('redirect/', views.QRCodeRedirectView.as_view(), name='redirect_view'),
|
path('redirect/', views.QRCodeRedirectView.as_view(), name='redirect_view'),
|
||||||
# TODO not always store activity_pk in url
|
# TODO not always store activity_pk in url
|
||||||
# path('activity/<int:activity_pk>/dishes/add/', views.DishCreateView.as_view(), name='dish_create'),
|
path('activity/<int:activity_pk>/dishes/add/', views.DishCreateView.as_view(), name='dish_create'),
|
||||||
# path('activity/<int:activity_pk>/dishes/', views.DishListView.as_view(), name='dish_list'),
|
path('activity/<int:activity_pk>/dishes/', views.DishListView.as_view(), name='dish_list'),
|
||||||
# path('activity/<int:activity_pk>/dishes/<int:pk>/', views.DishDetailView.as_view(), name='dish_detail'),
|
path('activity/<int:activity_pk>/dishes/<int:pk>/', views.DishDetailView.as_view(), name='dish_detail'),
|
||||||
# path('activity/<int:activity_pk>/dishes/<int:pk>/update/', views.DishUpdateView.as_view(), name='dish_update'),
|
path('activity/<int:activity_pk>/dishes/<int:pk>/update/', views.DishUpdateView.as_view(), name='dish_update'),
|
||||||
# path('activity/<int:activity_pk>/dishes/<int:pk>/delete/', views.DishDeleteView.as_view(), name='dish_delete'),
|
path('activity/<int:activity_pk>/dishes/<int:pk>/delete/', views.DishDeleteView.as_view(), name='dish_delete'),
|
||||||
# path('activity/<int:activity_pk>/order/', views.OrderCreateView.as_view(), name='order_create'),
|
path('activity/<int:activity_pk>/order/', views.OrderCreateView.as_view(), name='order_create'),
|
||||||
# path('activity/<int:activity_pk>/orders/', views.OrderListView.as_view(), name='order_list'),
|
path('activity/<int:activity_pk>/orders/', views.OrderListView.as_view(), name='order_list'),
|
||||||
# path('activity/<int:activity_pk>/orders/served', views.ServedOrderListView.as_view(), name='served_order_list'),
|
path('activity/<int:activity_pk>/orders/served', views.ServedOrderListView.as_view(), name='served_order_list'),
|
||||||
# path('activity/<int:activity_pk>/kitchen/', views.KitchenView.as_view(), name='kitchen'),
|
path('activity/<int:activity_pk>/kitchen/', views.KitchenView.as_view(), name='kitchen'),
|
||||||
# path('recipe/add/', views.RecipeCreateView.as_view(), name='recipe_create'),
|
path('recipe/add/', views.RecipeCreateView.as_view(), name='recipe_create'),
|
||||||
# path('recipe/', views.RecipeListView.as_view(), name='recipe_list'),
|
path('recipe/', views.RecipeListView.as_view(), name='recipe_list'),
|
||||||
# path('recipe/<int:pk>/', views.RecipeDetailView.as_view(), name='recipe_detail'),
|
path('recipe/<int:pk>/', views.RecipeDetailView.as_view(), name='recipe_detail'),
|
||||||
# path('recipe/<int:pk>/update/', views.RecipeUpdateView.as_view(), name='recipe_update'),
|
path('recipe/<int:pk>/update/', views.RecipeUpdateView.as_view(), name='recipe_update'),
|
||||||
# path('update/ingredients/<int:pk>/recipe/', views.UseRecipeView.as_view(), name='recipe_use'),
|
path('update/ingredients/<int:pk>/recipe/', views.UseRecipeView.as_view(), name='recipe_use'),
|
||||||
# path('ajax/get_ingredients/', views.get_ingredients_for_recipe, name='get_ingredients'),
|
path('ajax/get_ingredients/', views.get_ingredients_for_recipe, name='get_ingredients'),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user