Ultron/ultron/planning/forms.py

66 lines
2.2 KiB
Python
Raw Normal View History

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",
2021-12-09 16:53:44 +01:00
) # , 'gymnasts'
widgets = {
2021-12-19 09:30:51 +01:00
"place": forms.HiddenInput(),
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
# 'gymnasts': forms.MultipleChoiceField(choices=MYCHOICES, widget=forms.SelectMultiple)
2021-12-19 09:30:51 +01:00
"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
}
)
)
2021-12-18 22:40:15 +01:00
# Nécessaire pour le 'ModelMultipleChoiceField' apparement
2021-12-09 16:53:44 +01:00
# class Media:
# css = {'all':('/static/admin/css/widgets.css',),}
# js = ('/admin/jquery.js','/admin/jsi18n/') # OLD
2021-12-19 09:30:51 +01:00
# js = ('/admin/jsi18n/', ) # NEW