2015-04-13 18:56:43 +02:00
|
|
|
from django import forms
|
2015-07-22 22:08:59 +02:00
|
|
|
from calendrier.models import Event, Participants
|
2016-06-21 00:33:32 +02:00
|
|
|
from gestion.models import ErnestoUser
|
2020-09-10 15:06:53 +02:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2015-04-13 18:56:43 +02:00
|
|
|
|
2016-07-14 01:58:52 +02:00
|
|
|
|
2015-09-23 08:08:26 +02:00
|
|
|
class ModifEventForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Event
|
2016-06-25 01:22:01 +02:00
|
|
|
exclude = ['slug']
|
2015-09-23 08:08:26 +02:00
|
|
|
widgets = {
|
2016-07-14 01:58:52 +02:00
|
|
|
'description': forms.Textarea(attrs={
|
2020-09-10 15:06:53 +02:00
|
|
|
"placeholder": _("facultatif, balises html supportées")}),
|
2016-07-14 01:58:52 +02:00
|
|
|
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
|
|
|
|
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
|
2020-09-10 15:06:53 +02:00
|
|
|
'fin': forms.TextInput(attrs={"placeholder": _('hh:mm facultatif')})
|
2015-09-23 08:08:26 +02:00
|
|
|
}
|
|
|
|
|
2016-07-14 01:58:52 +02:00
|
|
|
|
2015-09-23 08:08:26 +02:00
|
|
|
|
2015-04-13 18:56:43 +02:00
|
|
|
class EventForm(forms.ModelForm):
|
2020-09-10 15:06:53 +02:00
|
|
|
|
2016-07-14 01:58:52 +02:00
|
|
|
|
2015-04-13 18:56:43 +02:00
|
|
|
class Meta:
|
|
|
|
model = Event
|
2016-06-25 01:22:01 +02:00
|
|
|
exclude = ['slug']
|
2015-04-13 18:56:43 +02:00
|
|
|
widgets = {
|
2016-07-14 01:58:52 +02:00
|
|
|
'nomcourt': forms.TextInput(
|
2020-09-10 15:06:53 +02:00
|
|
|
attrs={"placeholder": _('9 caractères max')}),
|
2016-07-14 01:58:52 +02:00
|
|
|
'description': forms.Textarea(
|
2020-09-10 15:06:53 +02:00
|
|
|
attrs={"placeholder": _("facultatif, balises html supportées")}),
|
2016-07-14 01:58:52 +02:00
|
|
|
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
|
|
|
|
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
|
2020-09-10 15:06:53 +02:00
|
|
|
'fin': forms.TextInput(attrs={"placeholder": _('hh:mm facultatif')}),
|
2015-04-13 18:56:43 +02:00
|
|
|
}
|
2016-07-14 01:58:52 +02:00
|
|
|
|
|
|
|
|
2015-07-22 22:08:59 +02:00
|
|
|
class ParticipantsForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Participants
|
2016-06-21 00:33:32 +02:00
|
|
|
fields = ('reponse', 'details')
|
|
|
|
widgets = {
|
2016-07-14 01:58:52 +02:00
|
|
|
'details': forms.Textarea(
|
2020-09-10 15:06:53 +02:00
|
|
|
attrs={"placeholder": _("50 caractères max")}),
|
2016-06-21 00:33:32 +02:00
|
|
|
}
|
|
|
|
|
2016-07-14 01:58:52 +02:00
|
|
|
|
2016-06-21 00:33:32 +02:00
|
|
|
class ChangeDoodleName(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(ChangeDoodleName, self).__init__(*args, **kwargs)
|
2020-09-10 15:06:53 +02:00
|
|
|
self.fields['doodlename'].initial = self.instance.profile.get_doodlename()
|
2016-06-21 00:33:32 +02:00
|
|
|
|
|
|
|
def save(self, *args, **kwargs):
|
|
|
|
super(ChangeDoodleName, self).save(*args, **kwargs)
|
|
|
|
self.instance.profile.doodlename = self.cleaned_data['doodlename']
|
|
|
|
self.instance.profile.save()
|
2016-07-17 19:41:45 +02:00
|
|
|
self.instance.save()
|
2016-06-21 00:33:32 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = ErnestoUser
|
|
|
|
fields = ('doodlename',)
|