OpenSlides/openslides/assignment/forms.py

76 lines
2.5 KiB
Python
Raw Normal View History

2011-07-31 10:46:29 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
openslides.assignment.forms
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Forms for the assignment app.
2012-04-25 22:29:19 +02:00
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
2011-07-31 10:46:29 +02:00
:license: GNU GPL, see LICENSE for more details.
"""
2012-03-16 14:31:59 +01:00
from django import forms
2011-07-31 10:46:29 +02:00
from django.forms import ModelForm, Form, ModelChoiceField, Select
from utils.forms import CssClassMixin
from utils.translation_ext import ugettext as _
2011-07-31 10:46:29 +02:00
from participant.models import Profile
from assignment.models import Assignment
class AssignmentForm(ModelForm, CssClassMixin):
posts = forms.IntegerField(min_value=1, label=_("Number of available posts"))
2011-07-31 10:46:29 +02:00
class Meta:
model = Assignment
exclude = ('status', 'profile', 'elected')
2011-07-31 10:46:29 +02:00
class AssignmentRunForm(Form, CssClassMixin):
2011-07-31 10:46:29 +02:00
candidate = ModelChoiceField(
widget=Select(attrs={'class': 'medium-input'}),
queryset=Profile.objects.all().order_by('user__first_name'),
label=_("Nominate a participant"),
)
2012-03-16 14:31:59 +01:00
class ConfigForm(Form, CssClassMixin):
assignment_publish_winner_results_only = forms.BooleanField(
required=False,
label=_("Only publish voting results for selected winners (Projector view only)")
)
assignment_pdf_ballot_papers_selection = forms.ChoiceField(widget=forms.Select(),
required=False,
label=_("Number of ballot papers (selection)"),
choices=(
2012-03-16 14:31:59 +01:00
("1", _("Number of all delegates")),
("2", _("Number of all participants")),
("0", _("Use the following custum number"))
)
2012-03-16 14:31:59 +01:00
)
assignment_pdf_ballot_papers_number = forms.IntegerField(
widget=forms.TextInput(attrs={'class':'small-input'}),
required=False,
min_value=1,
label=_("Custom number of ballot papers")
)
assignment_pdf_title = forms.CharField(
widget=forms.TextInput(),
required=False,
label=_("Title for PDF document (all elections)")
)
assignment_pdf_preamble = forms.CharField(
widget=forms.Textarea(),
required=False,
label=_("Preamble text for PDF document (all elections)")
)
assignment_poll_vote_values = forms.ChoiceField(widget=forms.Select(),
required=False,
2012-06-23 15:36:02 +02:00
label=_("Election method"),
choices=(
("auto", _("Choose the right method.")),
2012-06-23 15:36:02 +02:00
("votes", _("Always one option per candidate.")),
("yesnoabstain", _("Always Yes-No-Abstain per candidate.")),
)
)