2021-12-09 16:53:44 +01:00
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
|
|
|
|
|
|
|
from ultron.people.models import Gymnast
|
|
|
|
from .models import Event
|
|
|
|
|
2021-12-19 09:30:51 +01:00
|
|
|
|
2021-12-09 16:53:44 +01:00
|
|
|
class EventForm(forms.ModelForm):
|
|
|
|
|
2021-12-18 22:40:15 +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",
|
2022-01-03 09:56:08 +01:00
|
|
|
)
|
2021-12-09 16:53:44 +01:00
|
|
|
widgets = {
|
2021-12-19 09:30:51 +01:00
|
|
|
"place": forms.HiddenInput(),
|
|
|
|
"eventtype": forms.Select(attrs={"class": "form-control"}),
|
|
|
|
"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(
|
|
|
|
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
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|