ernestophone.ens.fr/calendrier/forms.py
Martin Pépin 0f68f043df Supprime les RemovedInDjango18Warning
Ils s'agissait de l'absence de champs `exclude` ou `fields` dans les
formulaires de création et modifications d'événements dans le
calendrier.
2016-06-25 01:22:01 +02:00

55 lines
2.3 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.save()
self.instance.profile.save()
class Meta:
model = ErnestoUser
fields = ('doodlename',)