forms.py 1.17 KB
Newer Older
chris's avatar
chris committed
1 2
from django import forms
from models import Poll, Choice, Bulletin, Vote
3
from django.utils.translation import ugettext_lazy as _
chris's avatar
chris committed
4 5

class PollForm(forms.ModelForm):
6 7
    title = forms.CharField(label=_('title'))
    description = forms.CharField(widget=forms.Textarea, label=_('description'))
chris's avatar
chris committed
8 9
    class Meta:
        model = Poll
10
        fields = ('title','description')
chris's avatar
chris committed
11 12

class ChoiceForm(forms.ModelForm):
Christophe Siraut's avatar
Christophe Siraut committed
13 14 15 16 17 18 19 20 21 22
    choice = forms.DateTimeField(
        widget=forms.DateTimeInput(format='%d-%m-%Y %H:%M',
        attrs={'class':'hasdatepicker','size':'18',}),
        input_formats=['%d-%m-%Y %H:%M']
        )
    details = forms.CharField(
        required=False,
        max_length='200',
        widget=forms.TextInput(attrs={'size':'32',})
        )
chris's avatar
chris committed
23 24 25 26 27 28 29 30 31
    class Meta:
        model = Choice
        exclude = ('poll','votecount')

class BulletinForm(forms.ModelForm):
    class Meta:
        model = Bulletin

class VoteForm(forms.ModelForm):
Christophe Siraut's avatar
Christophe Siraut committed
32 33 34 35 36
    comment = forms.CharField(
        required=False,
        max_length=80,
        widget=forms.TextInput(attrs={'class':'comment'})
        )
chris's avatar
chris committed
37 38 39 40 41
    choice = forms.CharField()
    class Meta:
        model = Vote
        fields = ('choice','voice','comment')