ernestophone.ens.fr/calendrier/forms.py

56 lines
2.3 KiB
Python
Raw 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
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"}),
2015-09-23 08:08:26 +02:00
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
'fin': forms.TextInput(attrs={"placeholder": 'hh:mm facultatif'})
}
class SendMail(forms.Form):
message = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={"placeholder":"Remplir ici pour remplacer le mail automatique"}), required=False)
2015-04-13 18:56:43 +02:00
class EventForm(forms.ModelForm):
2015-09-23 08:08:26 +02:00
sendmail = forms.BooleanField(initial=False, label="Envoyer l'invitation à la liste fanfare", required=False)
2015-07-22 22:08:59 +02:00
message = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={"placeholder":"Remplir ici pour remplacer le mail automatique"}), required=False)
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"}),
2015-04-13 18:56:43 +02:00
'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-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.doodlename
def save(self, *args, **kwargs):
super(ChangeDoodleName, self).save(*args, **kwargs)
self.instance.profile.doodlename = self.cleaned_data['doodlename']
self.instance.save()
self.instance.profile.save()
class Meta:
model = ErnestoUser
fields = ('doodlename',)