1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-12-14 15:25:15 +01:00

First test irl

This commit is contained in:
Ehouarn
2025-12-13 20:37:06 +01:00
parent bac9ed2353
commit 918c9bbcf0
7 changed files with 43 additions and 24 deletions

View File

@@ -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__'