ernestophone.ens.fr/calendrier/forms.py

62 lines
2 KiB
Python
Raw Permalink Normal View History

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
from gestion.models import ErnestoUser
from django.utils.translation import gettext_lazy as _
2015-04-13 18:56:43 +02:00
2015-09-23 08:08:26 +02:00
class ModifEventForm(forms.ModelForm):
class Meta:
model = Event
exclude = ['slug']
2015-09-23 08:08:26 +02:00
widgets = {
'description': forms.Textarea(attrs={
"placeholder": _("facultatif, balises html supportées")}),
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
'fin': forms.TextInput(attrs={"placeholder": _('hh:mm facultatif')})
2015-09-23 08:08:26 +02:00
}
2015-09-23 08:08:26 +02:00
2015-04-13 18:56:43 +02:00
class EventForm(forms.ModelForm):
2015-04-13 18:56:43 +02:00
class Meta:
model = Event
exclude = ['slug']
2015-04-13 18:56:43 +02:00
widgets = {
'nomcourt': forms.TextInput(
attrs={"placeholder": _('9 caractères max')}),
'description': forms.Textarea(
attrs={"placeholder": _("facultatif, balises html supportées")}),
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
'fin': forms.TextInput(attrs={"placeholder": _('hh:mm facultatif')}),
2015-04-13 18:56:43 +02:00
}
2015-07-22 22:08:59 +02:00
class ParticipantsForm(forms.ModelForm):
class Meta:
model = Participants
fields = ('reponse', 'details')
widgets = {
'details': forms.Textarea(
attrs={"placeholder": _("50 caractères max")}),
}
class ChangeDoodleName(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ChangeDoodleName, self).__init__(*args, **kwargs)
self.fields['doodlename'].initial = self.instance.profile.get_doodlename()
def save(self, *args, **kwargs):
super(ChangeDoodleName, self).save(*args, **kwargs)
self.instance.profile.doodlename = self.cleaned_data['doodlename']
self.instance.profile.save()
self.instance.save()
class Meta:
model = ErnestoUser
fields = ('doodlename',)