ernestophone.ens.fr/calendrier/forms.py

60 lines
2 KiB
Python
Raw Permalink Normal View History

2015-04-13 18:56:43 +02:00
from django import forms
2021-04-29 00:27:33 +02:00
from django.utils.translation import gettext_lazy as _
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
2021-04-29 00:27:33 +02:00
exclude = ["slug"]
2015-09-23 08:08:26 +02:00
widgets = {
2021-04-29 00:27:33 +02:00
"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-04-13 18:56:43 +02:00
class EventForm(forms.ModelForm):
class Meta:
model = Event
2021-04-29 00:27:33 +02:00
exclude = ["slug"]
2015-04-13 18:56:43 +02:00
widgets = {
2021-04-29 00:27:33 +02:00
"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", "dont_play_main", "instrument","instrument_autre")
widgets = {
2021-04-29 00:27:33 +02:00
"details": forms.Textarea(attrs={"placeholder": _("50 caractères max")}),
}
class ChangeDoodleName(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ChangeDoodleName, self).__init__(*args, **kwargs)
2021-04-29 00:27:33 +02:00
self.fields["doodlename"].initial = self.instance.profile.get_doodlename()
def save(self, *args, **kwargs):
super(ChangeDoodleName, self).save(*args, **kwargs)
2021-04-29 00:27:33 +02:00
self.instance.profile.doodlename = self.cleaned_data["doodlename"]
self.instance.profile.save()
self.instance.save()
class Meta:
2021-04-29 00:27:33 +02:00
model = ErnestoUser
fields = ("doodlename",)