OpenSlides/openslides/assignment/forms.py

79 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
2012-07-10 11:27:06 +02:00
from django.utils.translation import ugettext_lazy as _, ugettext_noop
2011-07-31 10:46:29 +02:00
from openslides.utils.forms import CssClassMixin
from openslides.utils.person import PersonFormField
2012-07-10 11:27:06 +02:00
from openslides.assignment.models import Assignment
2011-07-31 10:46:29 +02:00
2012-07-10 11:27:06 +02:00
class AssignmentForm(forms.ModelForm, CssClassMixin):
posts = forms.IntegerField(min_value=1, initial=1,
2012-07-10 11:27:06 +02:00
label=_("Number of available posts"))
2011-07-31 10:46:29 +02:00
class Meta:
model = Assignment
exclude = ('status', 'elected')
2011-07-31 10:46:29 +02:00
2012-07-10 11:27:06 +02:00
class AssignmentRunForm(forms.Form, CssClassMixin):
candidate = PersonFormField(
2012-07-10 11:27:06 +02:00
widget=forms.Select(attrs={'class': 'medium-input'}),
label=_("Nominate a participant"),
)
2012-03-16 14:31:59 +01:00
2012-07-10 11:27:06 +02:00
class ConfigForm(forms.Form, CssClassMixin):
2012-03-16 14:31:59 +01:00
assignment_publish_winner_results_only = forms.BooleanField(
required=False,
2012-07-10 11:27:06 +02:00
label=_("Only publish voting results for selected winners "
"(Projector view only)")
2012-03-16 14:31:59 +01:00
)
2012-07-10 11:27:06 +02:00
assignment_pdf_ballot_papers_selection = forms.ChoiceField(
widget=forms.Select(),
2012-03-16 14:31:59 +01:00
required=False,
label=_("Number of ballot papers (selection)"),
choices=(
("NUMBER_OF_DELEGATES", _("Number of all delegates")),
("NUMBER_OF_ALL_PARTICIPANTS", _("Number of all participants")),
("CUSTOM_NUMBER", _("Use the following custom 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", _("Automatic assign of method.")),
2012-06-23 15:36:02 +02:00
("votes", _("Always one option per candidate.")),
("yesnoabstain", _("Always Yes-No-Abstain per candidate.")),
)
)