nk20/apps/sheets/forms.py

42 lines
966 B
Python

# Copyright (C) 2018-2022 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django import forms
from member.models import Club
from note_kfet.inputs import AmountInput, Autocomplete, DateTimePickerInput
from .models import Food, Meal, Sheet
class SheetForm(forms.ModelForm):
class Meta:
model = Sheet
fields = '__all__'
widgets = {
'date': DateTimePickerInput(),
}
class FoodForm(forms.ModelForm):
class Meta:
model = Food
exclude = ('sheet', )
widgets = {
'price': AmountInput(),
'club': Autocomplete(
model=Club,
attrs={"api_url": "/api/members/club/"},
),
}
class MealForm(forms.ModelForm):
class Meta:
model = Meal
exclude = ('sheet', )
widgets = {
'content': forms.CheckboxSelectMultiple(),
'price': AmountInput(),
}