ernestophone.ens.fr/calendrier/forms.py

77 lines
2.6 KiB
Python

from django import forms
from calendrier.models import Event, Participants
from gestion.models import ErnestoUser
class ModifEventForm(forms.ModelForm):
class Meta:
model = Event
exclude = ['slug']
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'})
}
class SendMail(forms.Form):
message = forms.CharField(
max_length=2000,
widget=forms.Textarea(
attrs={"placeholder":
"Remplir ici pour remplacer le mail automatique"}),
required=False)
class EventForm(forms.ModelForm):
sendmail = forms.BooleanField(
initial=False,
label="Envoyer l'invitation à la liste fanfare",
required=False)
message = forms.CharField(
max_length=2000,
widget=forms.Textarea(
attrs={"placeholder":
"Remplir ici pour remplacer le mail automatique"}),
required=False)
class Meta:
model = Event
exclude = ['slug']
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'})
}
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.profile.save()
self.instance.save()
class Meta:
model = ErnestoUser
fields = ('doodlename',)