Ultron/ultron/planning/forms.py

59 lines
1.7 KiB
Python
Raw Normal View History

2021-12-09 16:53:44 +01:00
from datetime import date
from django import forms
from .models import Event
2021-12-19 09:30:51 +01:00
2021-12-09 16:53:44 +01:00
class EventForm(forms.ModelForm):
2022-01-07 18:08:39 +01:00
# gymnasts = forms.ModelMultipleChoiceField(queryset=Gymnast.objects.all(),
# widget=FilteredSelectMultiple('Gymnast(s)', is_stacked=False))
2021-12-09 16:53:44 +01:00
class Meta:
model = Event
fields = (
2021-12-19 09:30:51 +01:00
"name",
"datebegin",
"dateend",
"place",
"eventtype",
"informations",
)
2021-12-09 16:53:44 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
"place": forms.HiddenInput(),
2022-01-06 17:59:21 +01:00
"eventtype": forms.Select(attrs={"class": "form-control selectpicker"}),
2021-12-19 09:30:51 +01:00
"name": forms.TextInput(
attrs={"class": "form-control", "placeholder": "Even's name"}
2021-12-09 16:53:44 +01:00
),
2021-12-19 09:30:51 +01:00
"datebegin": forms.DateTimeInput(
2021-12-09 16:53:44 +01:00
attrs={
2021-12-19 09:30:51 +01:00
"class": "form-control datetimepicker",
"placeholder": date.today().strftime("%Y-%m-%d 08:00"),
2021-12-09 16:53:44 +01:00
}
),
2021-12-19 09:30:51 +01:00
"dateend": forms.DateTimeInput(
2021-12-09 16:53:44 +01:00
attrs={
2021-12-19 09:30:51 +01:00
"class": "form-control datetimepicker",
"placeholder": date.today().strftime("%Y-%m-%d 18:00"),
2021-12-09 16:53:44 +01:00
}
),
2021-12-19 09:30:51 +01:00
"informations": forms.Textarea(
2021-12-09 16:53:44 +01:00
attrs={
2021-12-19 09:30:51 +01:00
"class": "form-control",
"placeholder": "Informations about the event…",
2021-12-09 16:53:44 +01:00
}
),
}
place_related = forms.CharField(
2022-02-06 17:39:26 +01:00
required=False,
2021-12-09 16:53:44 +01:00
widget=forms.TextInput(
attrs={
2021-12-19 09:30:51 +01:00
"class": "form-control",
"placeholder": "Searching place…",
"data-ref": "#id_place",
2021-12-09 16:53:44 +01:00
}
)
)